Don't perform integral promotions from an incompletion enumeration

type. Fixes PR8089 in a slightly different way than had been suggested.

llvm-svn: 113711
This commit is contained in:
Douglas Gregor
2010-09-12 03:38:25 +00:00
parent 391a9603a0
commit c87f4d4aba
2 changed files with 7 additions and 1 deletions

View File

@@ -1194,7 +1194,8 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) {
// We pre-calculate the promotion type for enum types.
if (const EnumType *FromEnumType = FromType->getAs<EnumType>())
if (ToType->isIntegerType())
if (ToType->isIntegerType() &&
!RequireCompleteType(From->getLocStart(), FromType, PDiag()))
return Context.hasSameUnqualifiedType(ToType,
FromEnumType->getDecl()->getPromotionType());

View File

@@ -90,3 +90,8 @@ typedef enum { }; // expected-warning{{typedef requires a name}}
enum PR7921E {
PR7921V = (PR7921E)(123) // expected-error {{expression is not an integer constant expression}}
};
void PR8089() {
enum E; // expected-error{{ISO C++ forbids forward references to 'enum' types}}
int a = (E)3; // expected-error{{cannot initialize a variable of type 'int' with an rvalue of type 'E'}}
}