Allow int: and void: tags, but warn.
This commit is contained in:
parent
18cc1b414b
commit
0295f817b8
@ -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")*/
|
||||
|
@ -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",
|
||||
|
4
sourcepawn/compiler/tests/ok-bad-int-cast.sp
Normal file
4
sourcepawn/compiler/tests/ok-bad-int-cast.sp
Normal file
@ -0,0 +1,4 @@
|
||||
public main()
|
||||
{
|
||||
new class = int:5;
|
||||
}
|
Loading…
Reference in New Issue
Block a user