-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
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index bcbf887..75e2c5b 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -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;
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index 17bd07f..3ddd097 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -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.