mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 01:58:44 +08:00
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:
@@ -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());
|
||||
|
||||
|
||||
@@ -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'}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user