[cfe-commits] r124924 - in /cfe/trunk: lib/Sema/AnalysisBasedWarnings.cpp test/SemaCXX/uninit-variables.cpp
Ted Kremenek
kremenek at apple.com
Fri Feb 4 17:18:18 PST 2011
Author: kremenek
Date: Fri Feb 4 19:18:18 2011
New Revision: 124924
URL: http://llvm.org/viewvc/llvm-project?rev=124924&view=rev
Log:
Don't suggest -Wuninitialized fixits for uninitialized enum types.
Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/SemaCXX/uninit-variables.cpp
Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=124924&r1=124923&r2=124924&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Fri Feb 4 19:18:18 2011
@@ -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";
Modified: cfe/trunk/test/SemaCXX/uninit-variables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/uninit-variables.cpp?rev=124924&r1=124923&r2=124924&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/uninit-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/uninit-variables.cpp Fri Feb 4 19:18:18 2011
@@ -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}}
+}
+
More information about the cfe-commits
mailing list