[cfe-commits] r128838 - in /cfe/trunk: lib/Sema/AnalysisBasedWarnings.cpp test/Sema/uninit-variables.c

Ted Kremenek kremenek at apple.com
Mon Apr 4 12:43:57 PDT 2011


Author: kremenek
Date: Mon Apr  4 14:43:57 2011
New Revision: 128838

URL: http://llvm.org/viewvc/llvm-project?rev=128838&view=rev
Log:
-Wuninitialized: don't issue fixit for initializer if a variable declaration already has an initializer.

Modified:
    cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
    cfe/trunk/test/Sema/uninit-variables.c

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=128838&r1=128837&r2=128838&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Mon Apr  4 14:43:57 2011
@@ -453,6 +453,10 @@
           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;

Modified: cfe/trunk/test/Sema/uninit-variables.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/uninit-variables.c?rev=128838&r1=128837&r2=128838&view=diff
==============================================================================
--- cfe/trunk/test/Sema/uninit-variables.c (original)
+++ cfe/trunk/test/Sema/uninit-variables.c Mon Apr  4 14:43:57 2011
@@ -92,7 +92,7 @@
 }
 
 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.





More information about the cfe-commits mailing list