summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-06 00:03:12 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-06 00:03:12 +0000
commitb2186fe23c98aa7ac50016374e718f6f475e5c5f (patch)
tree37f5aca72b4824452df15585ff26cee477cf6e95 /clang/lib
parent006f9353e15a4506baac3ffcaa3ee27963337bf5 (diff)
downloadbcm5719-llvm-b2186fe23c98aa7ac50016374e718f6f475e5c5f.tar.gz
bcm5719-llvm-b2186fe23c98aa7ac50016374e718f6f475e5c5f.zip
Make sure that EnumConstantDecls always get a type, even when they have type-dependent initializers.
llvm-svn: 86197
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 088c7dc7807..0616fca6b8c 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5362,21 +5362,25 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
llvm::APSInt EnumVal(32);
QualType EltTy;
- if (Val && !Val->isTypeDependent()) {
- // Make sure to promote the operand type to int.
- UsualUnaryConversions(Val);
- if (Val != val.get()) {
- val.release();
- val = Val;
- }
+ if (Val) {
+ if (Val->isTypeDependent())
+ EltTy = Context.DependentTy;
+ else {
+ // Make sure to promote the operand type to int.
+ UsualUnaryConversions(Val);
+ if (Val != val.get()) {
+ val.release();
+ val = Val;
+ }
- // C99 6.7.2.2p2: Make sure we have an integer constant expression.
- SourceLocation ExpLoc;
- if (!Val->isValueDependent() &&
- VerifyIntegerConstantExpression(Val, &EnumVal)) {
- Val = 0;
- } else {
- EltTy = Val->getType();
+ // C99 6.7.2.2p2: Make sure we have an integer constant expression.
+ SourceLocation ExpLoc;
+ if (!Val->isValueDependent() &&
+ VerifyIntegerConstantExpression(Val, &EnumVal)) {
+ Val = 0;
+ } else {
+ EltTy = Val->getType();
+ }
}
}
@@ -5398,6 +5402,8 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
}
}
+ assert(!EltTy.isNull() && "Enum constant with NULL type");
+
val.release();
return EnumConstantDecl::Create(Context, Enum, IdLoc, Id, EltTy,
Val, EnumVal);
OpenPOWER on IntegriCloud