]> granicus.if.org Git - clang/commitdiff
-Wuninitialized: don't issue fixit for initializer if a variable declaration already...
authorTed Kremenek <kremenek@apple.com>
Mon, 4 Apr 2011 19:43:57 +0000 (19:43 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 4 Apr 2011 19:43:57 +0000 (19:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128838 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/AnalysisBasedWarnings.cpp
test/Sema/uninit-variables.c

index bcbf887916be6654b3737ed0eb0288e210221b7d..75e2c5b8ac1a3873218dfa96e9eb48af650a417e 100644 (file)
@@ -453,6 +453,10 @@ public:
           continue;
       
         fixitIssued = true;
+        
+        // Don't issue a fixit if there is already an initializer.
+        if (vd->getInit())
+          continue;
 
         // Suggest possible initialization (if any).
         const char *initialization = 0;
index 17bd07f3e55640e90c1ec6c3fab7f5f701edb291..3ddd097c8f279226f6211a0018187eee8b5bf81d 100644 (file)
@@ -92,7 +92,7 @@ void test14() {
 }
 
 void test15() {
-  int x = x; // expected-warning{{variable 'x' is possibly uninitialized when used here}} expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}}
+  int x = x; // expected-warning{{variable 'x' is possibly uninitialized when used here}} expected-note{{variable 'x' is declared here}}
 }
 
 // Don't warn in the following example; shows dataflow confluence.