1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 07:29:33 +00:00

Disallowed empty enums.

This commit is contained in:
acqn 2020-08-07 17:40:40 +08:00 committed by Oliver Schmidt
parent 97065faf1a
commit fe44fe963f

View File

@ -549,8 +549,8 @@ static SymEntry* ParseEnumDecl (const char* Name)
ident Ident;
long MinConstant = 0;
unsigned long MaxConstant = 0;
const Type* NewType = type_int; /* new enumerator type */
const Type* MemberType = type_int; /* default enumerator type */
const Type* NewType = 0; /* new member type */
const Type* MemberType = type_int; /* default member type */
/* Accept forward definitions */
if (CurTok.Tok != TOK_LCURLY) {
@ -677,6 +677,11 @@ static SymEntry* ParseEnumDecl (const char* Name)
}
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 */
MemberType = GetEnumeratorType (MinConstant, MaxConstant, 0);
if (MemberType == 0) {