Disallow retagging enums or using implicit-int as an enum tag.

This commit is contained in:
David Anderson 2014-11-20 19:30:22 -08:00
parent f573bdf784
commit 673ff572c5
4 changed files with 43 additions and 9 deletions

View File

@ -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));

View File

@ -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",

View File

@ -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;
}

View File

@ -0,0 +1 @@
(11) : error 169: cannot tag an enum as implicit-int