Allow int: and void: tags, but warn.

This commit is contained in:
David Anderson 2014-12-10 02:36:30 -08:00
parent 18cc1b414b
commit 0295f817b8
3 changed files with 25 additions and 0 deletions

View File

@ -2205,6 +2205,25 @@ int lex(cell *lexvalue,char **lexsym)
tok->id = tSYMBOL;
strcpy(tok->str, sc_tokens[i - tFIRST]);
tok->len = strlen(tok->str);
} else if (*lptr == ':' &&
(i == tINT ||
i == tVOID))
{
// Special case 'int:' to its old behavior: an implicit view_as<> cast
// with Pawn's awful lowercase coercion semantics.
const char *token = sc_tokens[i - tFIRST];
switch (i) {
case tINT:
error(238, token, token);
break;
case tVOID:
error(239, token, token);
break;
}
lptr++;
tok->id = tLABEL;
strcpy(tok->str, token);
tok->len = strlen(tok->str);
} else {
tok->id = i;
errorset(sRESET,0); /* reset error flag (clear the "panic mode")*/

View File

@ -454,6 +454,8 @@ static const char *warnmsg[] = {
/*235*/ "public function lacks forward declaration (symbol \"%s\")\n",
/*236*/ "unknown parameter in substitution (incorrect #define pattern)\n",
/*237*/ "coercing functions to and from primitives is unsupported and will be removed in the future\n",
/*238*/ "'%s:' is an illegal cast; use view_as<%s>(expression)\n",
/*239*/ "'%s' is an illegal tag; use %s as a type\n",
#else
"\327 \275tr\242\231\227\266 %\204\305\206a\306\210\260",
"\214\343i\215 \330\371\213t/\321cro \365",

View File

@ -0,0 +1,4 @@
public main()
{
new class = int:5;
}