aboutsummaryrefslogtreecommitdiff
path: root/AST/Type.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-01-16 23:54:22 +0000
committerSteve Naroff <snaroff@apple.com>2008-01-16 23:54:22 +0000
commit67c49e892b50a9ccb64f7296e00c23c61a8b7186 (patch)
treeb45ac6b2a5b11cd219ced55c68558f93f436c1fd /AST/Type.cpp
parente3d7c24f282e061ca9dd9268127ca9a24d715ccf (diff)
Type::isArithmeticType(): disallow incomplete enum decls.
Bug submitted by Eli. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46102 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'AST/Type.cpp')
-rw-r--r--AST/Type.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/AST/Type.cpp b/AST/Type.cpp
index 78e0dbbb27..e59569d2d6 100644
--- a/AST/Type.cpp
+++ b/AST/Type.cpp
@@ -444,8 +444,11 @@ bool Type::isArithmeticType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() != BuiltinType::Void;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
- if (TT->getDecl()->getKind() == Decl::Enum)
- return true;
+ if (const EnumDecl *ED = dyn_cast<EnumDecl>(TT->getDecl()))
+ // GCC allows forward declaration of enum types (forbid by C99 6.7.2.3p2).
+ // If a body isn't seen by the time we get here, we exclude it from
+ // being allowed in arithmetic expressions.
+ return ED->isDefinition();
return isa<ComplexType>(CanonicalType) || isa<VectorType>(CanonicalType);
}