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);
}
EnumDecl(SourceLocation L, IdentifierInfo *Id, ScopedDecl *PrevDecl)
: TagDecl(Enum, L, Id, PrevDecl) {
ElementList = 0;
+ IntegerType = QualType();
}
/// defineElements - When created, EnumDecl correspond to a forward declared
return sizeof(enum e) ;
}
+enum gccForwardEnumExtension ve; // expected-warning {{ISO C forbids forward references to 'enum' types}}
+
+int test2(int i)
+{
+ ve + i; // expected-error{{invalid operands to binary expression ('enum gccForwardEnumExtension' and 'int')}}
+}