diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-04-04 19:43:57 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-04-04 19:43:57 +0000 |
commit | 5360c921a91dc43b442f069ba86d7b9df66362fc (patch) | |
tree | 2f95c29a267c7fe37ef5e255af8dca56fc9919d4 | |
parent | 5862f0e1ac29c5af8089b4bf119fd4493f6ab58c (diff) |
-Wuninitialized: don't issue fixit for initializer if a variable declaration already has an initializer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128838 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/AnalysisBasedWarnings.cpp | 4 | ||||
-rw-r--r-- | test/Sema/uninit-variables.c | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index bcbf887916..75e2c5b8ac 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -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; diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c index 17bd07f3e5..3ddd097c8f 100644 --- a/test/Sema/uninit-variables.c +++ b/test/Sema/uninit-variables.c @@ -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. |