diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index d6f9a21b..a05b6432 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -2968,7 +2968,7 @@ static void decl_enum(int vclass,int fstatic) lexpush(); break; } /* 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 */ tokeninfo(&val,&str); /* get the information */ strcpy(constname,str); /* save symbol name */ diff --git a/source/compiler/tests/anonymous_enum_tags.meta b/source/compiler/tests/anonymous_enum_tags.meta new file mode 100644 index 00000000..4d941e26 --- /dev/null +++ b/source/compiler/tests/anonymous_enum_tags.meta @@ -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-" + """ +} diff --git a/source/compiler/tests/anonymous_enum_tags.pwn b/source/compiler/tests/anonymous_enum_tags.pwn new file mode 100644 index 00000000..a5c580e0 --- /dev/null +++ b/source/compiler/tests/anonymous_enum_tags.pwn @@ -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(){}