aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-08-27 17:37:24 +0000
committerChris Lattner <sabre@nondot.org>2007-08-27 17:37:24 +0000
commitb7416f99b5d2483eb17a51c175857d6f51c54dbe (patch)
tree80b43f0385534e35d3e7f603dc5db4cae4b0a217
parent7946dd363beaa92e8d03ef199ffedaab58714058 (diff)
better error recovery for non-i-c-e enum constants.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41499 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Sema/SemaDecl.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 543d2af454..ba2fc80590 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -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.