Merge pull request #454 from Daniel-Cortez/unnamed-enum-tags-fix

Do not allow tags inside the braces of unnamed enums
This commit is contained in:
Y-Less 2019-11-07 01:39:27 +01:00 committed by GitHub
commit df323449ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 1 deletions

View File

@ -2967,7 +2967,7 @@ static void decl_enum(int vclass,int fstatic)
lexpush(); lexpush();
break; break;
} /* if */ } /* if */
idxtag=pc_addtag(NULL); /* optional explicit item tag */ idxtag=(enumname[0]=='\0') ? tag : pc_addtag(NULL); /* optional explicit item tag */
if (needtoken(tSYMBOL)) { /* read in (new) token */ if (needtoken(tSYMBOL)) { /* read in (new) token */
tokeninfo(&val,&str); /* get the information */ tokeninfo(&val,&str); /* get the information */
strcpy(constname,str); /* save symbol name */ strcpy(constname,str); /* save symbol name */

View File

@ -0,0 +1,7 @@
{
'test_type': 'output_check',
'errors': """
anonymous_enum_tags.pwn(4) : error 001: expected token: "-identifier-", but found "-label-"
anonymous_enum_tags.pwn(11) : error 001: expected token: "-identifier-", but found "-label-"
"""
}

View File

@ -0,0 +1,29 @@
enum
{
CONST1,
Float:CONST2, // error
CONST3
};
enum Float:
{
CONST4,
_:CONST5, // error
CONST6
};
enum eNamed1
{
CONST7,
Float:CONST8,
CONST9
};
enum Float:eNamed2
{
CONST10,
Float:CONST11,
CONST12
};
main(){}