From 5360c921a91dc43b442f069ba86d7b9df66362fc Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 4 Apr 2011 19:43:57 +0000 Subject: [PATCH] -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 --- lib/Sema/AnalysisBasedWarnings.cpp | 4 ++++ test/Sema/uninit-variables.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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. -- 2.40.0