Disallowed empty enums.
This commit is contained in:
@@ -549,8 +549,8 @@ static SymEntry* ParseEnumDecl (const char* Name)
|
|||||||
ident Ident;
|
ident Ident;
|
||||||
long MinConstant = 0;
|
long MinConstant = 0;
|
||||||
unsigned long MaxConstant = 0;
|
unsigned long MaxConstant = 0;
|
||||||
const Type* NewType = type_int; /* new enumerator type */
|
const Type* NewType = 0; /* new member type */
|
||||||
const Type* MemberType = type_int; /* default enumerator type */
|
const Type* MemberType = type_int; /* default member type */
|
||||||
|
|
||||||
/* Accept forward definitions */
|
/* Accept forward definitions */
|
||||||
if (CurTok.Tok != TOK_LCURLY) {
|
if (CurTok.Tok != TOK_LCURLY) {
|
||||||
@@ -677,6 +677,11 @@ static SymEntry* ParseEnumDecl (const char* Name)
|
|||||||
}
|
}
|
||||||
ConsumeRCurly ();
|
ConsumeRCurly ();
|
||||||
|
|
||||||
|
/* Check if there have been any members. Error if none */
|
||||||
|
if (NewType == 0) {
|
||||||
|
Error ("Empty enum is invalid");
|
||||||
|
}
|
||||||
|
|
||||||
/* This evaluates the underlying type of the whole enum */
|
/* This evaluates the underlying type of the whole enum */
|
||||||
MemberType = GetEnumeratorType (MinConstant, MaxConstant, 0);
|
MemberType = GetEnumeratorType (MinConstant, MaxConstant, 0);
|
||||||
if (MemberType == 0) {
|
if (MemberType == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user