]> granicus.if.org Git - clang/commitdiff
better error recovery for non-i-c-e enum constants.
authorChris Lattner <sabre@nondot.org>
Mon, 27 Aug 2007 17:37:24 +0000 (17:37 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 27 Aug 2007 17:37:24 +0000 (17:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41499 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaDecl.cpp

index 543d2af4544a478d67b98f5ef124d7055a587f39..ba2fc80590cc5e456554ced438ed79c98f9b1375 100644 (file)
@@ -942,19 +942,23 @@ Sema::DeclTy *Sema::ParseEnumConstant(Scope *S, DeclTy *theEnumDecl,
       Diag(ExpLoc, diag::err_enum_value_not_integer_constant_expr, 
            Id->getName());
       // FIXME: Don't leak memory: delete Val;
-      return 0;
+      Val = 0;  // Just forget about it.
     }
     EltTy = Val->getType();
-  } else if (LastEnumConst) {
-    // Assign the last value + 1.
-    EnumVal = LastEnumConst->getInitVal();
-    ++EnumVal;
-    // FIXME: detect overflow!
-    EltTy = LastEnumConst->getType();
-  } else {
-    // First value, set to zero.
-    EltTy = Context.IntTy;
-    // FIXME: Resize EnumVal to the size of int.
+  }
+  
+  if (!Val) {
+    if (LastEnumConst) {
+      // Assign the last value + 1.
+      EnumVal = LastEnumConst->getInitVal();
+      ++EnumVal;
+      // FIXME: detect overflow!
+      EltTy = LastEnumConst->getType();
+    } else {
+      // First value, set to zero.
+      EltTy = Context.IntTy;
+      // FIXME: Resize EnumVal to the size of int.
+    }
   }
   
   // TODO: Default promotions to int/uint.