Improve error messaging.
This commit is contained in:
parent
ed4cca0225
commit
a15153e9b8
@ -3341,8 +3341,10 @@ static int parse_new_typeexpr(typeinfo_t *type, const token_t *first, int flags)
|
||||
break;
|
||||
}
|
||||
type->dim[type->numdim++] = 0;
|
||||
if (!needtoken(']'))
|
||||
if (!matchtoken(']')) {
|
||||
error(140);
|
||||
goto err_out;
|
||||
}
|
||||
} while (matchtoken('['));
|
||||
type->ident = iARRAY;
|
||||
}
|
||||
|
@ -183,6 +183,7 @@ static char *errmsg[] = {
|
||||
/*137*/ "cannot mix reference and array types\n",
|
||||
/*138*/ "const was specified twice\n",
|
||||
/*139*/ "could not find type \"%s\"\n",
|
||||
/*140*/ "new-style array types cannot specify dimension sizes as part of their type\n",
|
||||
#else
|
||||
"\250\264\307\231\271k\214:\234\317bu\201fo\223\204\220\012",
|
||||
"\202l\224\252s\205g\370\346e\233\201(\242\250\324\273\202) \256 f\247low ea\274 \042c\342e\042\012",
|
||||
|
15
sourcepawn/compiler/tests/fail-bad-arg-decls.sp
Normal file
15
sourcepawn/compiler/tests/fail-bad-arg-decls.sp
Normal file
@ -0,0 +1,15 @@
|
||||
stock A(int)
|
||||
{
|
||||
}
|
||||
|
||||
stock B(int[5] N)
|
||||
{
|
||||
}
|
||||
|
||||
stock C(int:N)
|
||||
{
|
||||
}
|
||||
|
||||
public main()
|
||||
{
|
||||
}
|
3
sourcepawn/compiler/tests/fail-bad-arg-decls.txt
Normal file
3
sourcepawn/compiler/tests/fail-bad-arg-decls.txt
Normal file
@ -0,0 +1,3 @@
|
||||
(1) : error 001: expected token: "-identifier-", but found ")"
|
||||
(5) : error 140: new-style array types cannot specify dimension sizes as part of their type
|
||||
(9) : error 001: expected token: "-identifier-", but found ":"
|
@ -23,16 +23,22 @@ stock E(E2 t)
|
||||
{
|
||||
}
|
||||
|
||||
stock F(int n[10]) {
|
||||
stock F(const int n[10]) {
|
||||
}
|
||||
|
||||
stock G(int& n)
|
||||
{
|
||||
}
|
||||
|
||||
public main()
|
||||
{
|
||||
new x[10]
|
||||
new t
|
||||
A(1)
|
||||
B(x)
|
||||
C(x)
|
||||
D(E1:5)
|
||||
E(E2:5)
|
||||
F(x)
|
||||
G(t)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user