diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index c38c83ad..d8e5f037 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -4593,14 +4593,20 @@ static void decl_enum(int vclass) * pc_addtag() here */ if (lex(&val,&str)==tLABEL) { - int flags = ENUMTAG; - if (isupper(*str)) - flags |= FIXEDTAG; - tag = pc_addtag_flags(str, flags); - spec = deduce_layout_spec_by_tag(tag); - if (!can_redef_layout_spec(spec, Layout_Enum)) - error(110, str, layout_spec_name(spec)); - explicittag=TRUE; + if (pc_findtag(str) == 0) { + error(169); + tag = 0; + explicittag = FALSE; + } else { + int flags = ENUMTAG; + if (isupper(*str)) + flags |= FIXEDTAG; + tag = pc_addtag_flags(str, flags); + spec = deduce_layout_spec_by_tag(tag); + if (!can_redef_layout_spec(spec, Layout_Enum)) + error(110, str, layout_spec_name(spec)); + explicittag=TRUE; + } } else { lexpush(); tag=0; @@ -4619,6 +4625,8 @@ static void decl_enum(int vclass) if (!can_redef_layout_spec(spec, Layout_Enum)) error(110, enumname, layout_spec_name(spec)); } else { + error(168); + spec = deduce_layout_spec_by_name(enumname); if (!can_redef_layout_spec(spec, Layout_Enum)) error(110, enumname, layout_spec_name(spec)); diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp index 842bef3c..f9bd8f8d 100644 --- a/sourcepawn/compiler/sc5-in.scp +++ b/sourcepawn/compiler/sc5-in.scp @@ -210,7 +210,9 @@ static const char *errmsg[] = { /*164*/ "allocated array type '%s' doesn't match original type '%s'\n", /*165*/ "cannot create dynamic arrays in static scope - did you mean to create a fixed-length array with brackets after the variable name?\n", /*166*/ "cannot use 'this' outside of a methodmap method or property\n", -/*167*/ "cannot use delete, %s do not have destructors\n", +/*167*/ "cannot use delete, %s do not have destructors\n", +/*168*/ "re-tagging enums is no longer supported\n", +/*169*/ "cannot tag an enum as implicit-int\n", #else "\315e\306\227\266k\217:\235\277bu\201fo\220\204\223\012", "\202l\224\250s\205g\346\356e\233\201(\243\315\214\267\202) \253 f\255low ea\305 \042c\353e\042\012", diff --git a/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.sp b/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.sp new file mode 100644 index 00000000..0ac7b42b --- /dev/null +++ b/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.sp @@ -0,0 +1,23 @@ +native Float:float(x); +native Float:FloatMul(Float:oper1, Float:oper2); + +stock Float:operator*(Float:oper1, oper2) +{ + return FloatMul(oper1, float(oper2)); +} + +native Float:GetRandomFloat(); + +enum _:Rocketeer { + bool:bActivated, + iRockets[20] +}; + +public OnPluginStart() +{ + decl Float:fAngles[3]; + + fAngles[0] = GetRandomFloat() * 360; + fAngles[1] = GetRandomFloat() * 360; + fAngles[2] = GetRandomFloat() * 360; +} diff --git a/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.txt b/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.txt new file mode 100644 index 00000000..e04c048c --- /dev/null +++ b/sourcepawn/compiler/tests/fail-tag-enum-as-implicit-int.txt @@ -0,0 +1 @@ +(11) : error 169: cannot tag an enum as implicit-int