aboutsummaryrefslogtreecommitdiff
path: root/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Sema/SemaDecl.cpp')
-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.