From: Richard Trieu Date: Fri, 26 Sep 2014 23:48:30 +0000 (+0000) Subject: Add back checking for condition of conditional operator for -Wuninitialized X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ce2184600e4a36abd952695fa6579b1c15d58dd;p=clang Add back checking for condition of conditional operator for -Wuninitialized git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218556 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index abbf4b2bb2..9203df3fe5 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -8348,6 +8348,7 @@ namespace { } if (ConditionalOperator *CO = dyn_cast(E)) { + Visit(CO->getCond()); HandleValue(CO->getTrueExpr()); HandleValue(CO->getFalseExpr()); return; diff --git a/test/SemaCXX/uninitialized.cpp b/test/SemaCXX/uninitialized.cpp index d6331965ab..a7997e4268 100644 --- a/test/SemaCXX/uninitialized.cpp +++ b/test/SemaCXX/uninitialized.cpp @@ -50,6 +50,7 @@ int x = x++; // expected-warning {{variable 'x' is uninitialized when used withi int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}} int z = ++ref(z); // expected-warning {{variable 'z' is uninitialized when used within its own initialization}} int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}} +int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}} void test_stuff () { int a = a; // no-warning: used to signal intended lack of initialization. @@ -83,6 +84,8 @@ void test_stuff () { int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}} int z = ++ref(z); // expected-warning {{variable 'z' is uninitialized when used within its own initialization}} int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}} + int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}} + for (;;) { int a = a; // no-warning: used to signal intended lack of initialization. @@ -116,6 +119,8 @@ void test_stuff () { int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}} int z = ++ref(z); // expected-warning {{variable 'z' is uninitialized when used within its own initialization}} int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}} + int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}} + } } @@ -522,6 +527,8 @@ namespace statics { static int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}} static int z = ++ref(z); // expected-warning {{variable 'z' is uninitialized when used within its own initialization}} static int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}} + static int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}} + void test() { static int a = a; // no-warning: used to signal intended lack of initialization. @@ -555,7 +562,9 @@ namespace statics { static int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{static variable 'y' is suspiciously used within its own initialization}} static int z = ++ref(z); // expected-warning {{static variable 'z' is suspiciously used within its own initialization}} static int aa = (ref(aa) += 10); // expected-warning {{static variable 'aa' is suspiciously used within its own initialization}} - for (;;) { + static int bb = bb ? x : y; // expected-warning {{static variable 'bb' is suspiciously used within its own initialization}} + + for (;;) { static int a = a; // no-warning: used to signal intended lack of initialization. static int b = b + 1; // expected-warning {{static variable 'b' is suspiciously used within its own initialization}} static int c = (c + c); // expected-warning 2{{static variable 'c' is suspiciously used within its own initialization}} @@ -587,6 +596,7 @@ namespace statics { static int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{static variable 'y' is suspiciously used within its own initialization}} static int z = ++ref(z); // expected-warning {{static variable 'z' is suspiciously used within its own initialization}} static int aa = (ref(aa) += 10); // expected-warning {{static variable 'aa' is suspiciously used within its own initialization}} + static int bb = bb ? x : y; // expected-warning {{static variable 'bb' is suspiciously used within its own initialization}} } } }