Show symbol name with indeterminate array size warning (#370)

* Show symbol name with indeterminate array size warning

* Update older test to account for bug fix

* Add tests
This commit is contained in:
spacemud 2018-10-15 16:34:33 +01:00 committed by Barnaby Keene
parent 35fa8d4485
commit 19dabbbeb0
4 changed files with 15 additions and 2 deletions

View File

@ -1385,7 +1385,7 @@ static int hier2(value *lval)
else
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(224,sym->name); /* indeterminate array size in "sizeof" expression */
} /* if */
ldconst(lval->constval,sPRI);
while (paranthese--)

View File

@ -0,0 +1,6 @@
{
'test_type': 'output_check',
'errors': """
empty_symbol_name_indeterminate_array_size_gh_338.pwn(2) : warning 224: indeterminate array size in "sizeof" expression (symbol "arr")
"""
}

View File

@ -0,0 +1,7 @@
f(const arr[]) {
new tmp = sizeof(arr);
#pragma unused arr, tmp
}
main () {
f("");
}

View File

@ -5,6 +5,6 @@ md_array_size_chk_gh_314.pwn(1) : error 009: invalid array size (negative, zero
md_array_size_chk_gh_314.pwn(2) : error 009: invalid array size (negative, zero or out of bounds)
md_array_size_chk_gh_314.pwn(3) : error 009: invalid array size (negative, zero or out of bounds)
md_array_size_chk_gh_314.pwn(5) : error 009: invalid array size (negative, zero or out of bounds)
md_array_size_chk_gh_314.pwn(30) : warning 224: indeterminate array size in "sizeof" expression (symbol "")
md_array_size_chk_gh_314.pwn(30) : warning 224: indeterminate array size in "sizeof" expression (symbol "arr1")
"""
}