From b7416f99b5d2483eb17a51c175857d6f51c54dbe Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 27 Aug 2007 17:37:24 +0000 Subject: [PATCH] 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 --- Sema/SemaDecl.cpp | 26 +++++++++++++++----------- 1 file 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. -- 2.50.1