]> granicus.if.org Git - clang/commitdiff
Add back checking for condition of conditional operator for -Wuninitialized
authorRichard Trieu <rtrieu@google.com>
Fri, 26 Sep 2014 23:48:30 +0000 (23:48 +0000)
committerRichard Trieu <rtrieu@google.com>
Fri, 26 Sep 2014 23:48:30 +0000 (23:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218556 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/uninitialized.cpp

index abbf4b2bb240aa0e683e15e2c666d115b386ba3c..9203df3fe5b74ec7318113c1be6ebbc740c8beb6 100644 (file)
@@ -8348,6 +8348,7 @@ namespace {
       }
 
       if (ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E)) {
+        Visit(CO->getCond());
         HandleValue(CO->getTrueExpr());
         HandleValue(CO->getFalseExpr());
         return;
index d6331965ab4ef9689ec00e34dd7d1049746b3d23..a7997e4268c539b8ff255025c9fea00b6fb18fd3 100644 (file)
@@ -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}}
     }
   }
 }