Improve error messaging.

This commit is contained in:
David Anderson 2014-07-03 00:21:18 -07:00
parent ed4cca0225
commit a15153e9b8
5 changed files with 29 additions and 2 deletions

View File

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

View File

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

View File

@ -0,0 +1,15 @@
stock A(int)
{
}
stock B(int[5] N)
{
}
stock C(int:N)
{
}
public main()
{
}

View 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 ":"

View File

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