From 013084e18113d50bb5a9642b41b417dbf07babd9 Mon Sep 17 00:00:00 2001 From: Daniel_Cortez Date: Mon, 30 Sep 2019 19:01:34 +0700 Subject: [PATCH 1/2] Fix tags being silently ignored in anonymous enums --- source/compiler/sc1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */ From 11b1f5d8c2e31d8b27bab7cab3542732c1d8fb3a Mon Sep 17 00:00:00 2001 From: Daniel_Cortez Date: Mon, 30 Sep 2019 19:02:12 +0700 Subject: [PATCH 2/2] Add tests --- .../compiler/tests/anonymous_enum_tags.meta | 7 +++++ source/compiler/tests/anonymous_enum_tags.pwn | 29 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 source/compiler/tests/anonymous_enum_tags.meta create mode 100644 source/compiler/tests/anonymous_enum_tags.pwn 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(){}