Don't suggest -Wuninitialized fixits for uninitialized enum types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124924 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 0e7846f..63f561d 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -430,7 +430,7 @@
// Suggest possible initialization (if any).
const char *initialization = 0;
QualType vdTy = vd->getType().getCanonicalType();
-
+
if (vdTy->getAs<ObjCObjectPointerType>()) {
// Check if 'nil' is defined.
if (S.PP.getMacroInfo(&S.getASTContext().Idents.get("nil")))
@@ -442,6 +442,8 @@
initialization = " = 0.0";
else if (vdTy->isBooleanType() && S.Context.getLangOptions().CPlusPlus)
initialization = " = false";
+ else if (vdTy->isEnumeralType())
+ continue;
else if (vdTy->isScalarType())
initialization = " = 0";
diff --git a/test/SemaCXX/uninit-variables.cpp b/test/SemaCXX/uninit-variables.cpp
index cc5018a..a016937 100644
--- a/test/SemaCXX/uninit-variables.cpp
+++ b/test/SemaCXX/uninit-variables.cpp
@@ -41,3 +41,11 @@
return x; // expected-warning{{variable 'x' is possibly uninitialized when used here}}
}
+enum test4_A {
+ test4_A_a, test_4_A_b
+};
+test4_A test4() {
+ test4_A a; // expected-note{{variable 'a' is declared here}}
+ return a; // expected-warning{{variable 'a' is possibly uninitialized when used here}}
+}
+