Make sizeof on indeterminate arrays an error.
This commit is contained in:
parent
6d507ceb27
commit
f08e53f5d2
@ -1702,7 +1702,7 @@ static int hier2(value *lval)
|
||||
lval->constval=array_levelsize(sym,level);
|
||||
}
|
||||
if (lval->constval==0 && strchr((char *)lptr,PREPROC_TERM)==NULL)
|
||||
error(224,st); /* indeterminate array size in "sizeof" expression */
|
||||
error(163,st); /* indeterminate array size in "sizeof" expression */
|
||||
} /* if */
|
||||
ldconst(lval->constval,sPRI);
|
||||
while (paranthese--)
|
||||
@ -1756,7 +1756,7 @@ static int hier2(value *lval)
|
||||
lval->constval=array_levelsize(sym,level);
|
||||
}
|
||||
if (lval->constval==0 && strchr((char *)lptr,PREPROC_TERM)==NULL)
|
||||
error(224,st); /* indeterminate array size in "sizeof" expression */
|
||||
error(163,st); /* indeterminate array size in "sizeof" expression */
|
||||
} /* if */
|
||||
ldconst(lval->constval,sPRI);
|
||||
while (paranthese--)
|
||||
@ -2890,7 +2890,7 @@ static int nesting=0;
|
||||
if (asz!=NULL) {
|
||||
array_sz=asz->value;
|
||||
if (array_sz==0)
|
||||
error(224,arg[argidx].name); /* indeterminate array size in "sizeof" expression */
|
||||
error(163,arg[argidx].name); /* indeterminate array size in "sizeof" expression */
|
||||
} else {
|
||||
array_sz=1;
|
||||
} /* if */
|
||||
|
@ -206,6 +206,7 @@ static const char *errmsg[] = {
|
||||
/*160*/ "brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given\n",
|
||||
/*161*/ "brackets after variable name indicate a fixed-size array, but a dynamic size was given - did you mean to use 'new %s[size]' syntax?\n",
|
||||
/*162*/ "cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name?\n",
|
||||
/*163*/ "indeterminate array size in \"sizeof\" expression (symbol \"%s\")\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",
|
||||
@ -429,7 +430,7 @@ static const char *warnmsg[] = {
|
||||
/*221*/ "label name \"%s\" shadows tag name\n",
|
||||
/*222*/ "number of digits exceeds rational number precision\n",
|
||||
/*223*/ "redundant \"sizeof\": argument size is always 1 (symbol \"%s\")\n",
|
||||
/*224*/ "indeterminate array size in \"sizeof\" expression (symbol \"%s\")\n",
|
||||
/*224*/ "unused\n",
|
||||
/*225*/ "unreachable code\n",
|
||||
/*226*/ "a variable is assigned to itself (symbol \"%s\")\n",
|
||||
/*227*/ "more initializers than enum fields\n",
|
||||
|
@ -0,0 +1,8 @@
|
||||
native print(const char[] str);
|
||||
native printnum(num);
|
||||
|
||||
public main()
|
||||
{
|
||||
char[] egg = "!\n";
|
||||
return sizeof(egg);
|
||||
}
|
@ -0,0 +1 @@
|
||||
(7) : error 163: indeterminate array size in "sizeof" expression (symbol "egg")
|
Loading…
Reference in New Issue
Block a user