]> granicus.if.org Git - clang/commitdiff
Don't suggest -Wuninitialized fixits for uninitialized enum types.
authorTed Kremenek <kremenek@apple.com>
Sat, 5 Feb 2011 01:18:18 +0000 (01:18 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 5 Feb 2011 01:18:18 +0000 (01:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124924 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/AnalysisBasedWarnings.cpp
test/SemaCXX/uninit-variables.cpp

index 0e7846f021ad64997c56257637014f8013a95f08..63f561d6ab190ce3c0e7c393f9b8549ebee1deb6 100644 (file)
@@ -430,7 +430,7 @@ public:
         // 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 @@ public:
           initialization = " = 0.0";
         else if (vdTy->isBooleanType() && S.Context.getLangOptions().CPlusPlus)
           initialization = " = false";
+        else if (vdTy->isEnumeralType())
+          continue;
         else if (vdTy->isScalarType())
           initialization = " = 0";
       
index cc5018a5e860cb5cd6ea88349d23812a38d87c58..a016937925a78421ca8c8926163ee5c042198763 100644 (file)
@@ -41,3 +41,11 @@ unsigned test3_c() {
   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}}
+}
+