Show correct line for unused symbol warning for global symbols
Fixes #252.
This commit is contained in:
parent
a47bd9de76
commit
05582c8c0d
@ -4808,11 +4808,9 @@ static int testsymbols(symbol *root,int level,int testlabs,int testconst)
|
||||
if (sym->parent!=NULL)
|
||||
break; /* hierarchical data type */
|
||||
if ((sym->usage & (uWRITTEN | uREAD | uSTOCK | uPUBLIC))==0) {
|
||||
if (testconst)
|
||||
errorset(sSETPOS,sym->lnumber);
|
||||
errorset(sSETPOS,sym->lnumber);
|
||||
error(203,sym->name,sym->lnumber); /* symbol isn't used (and not stock) */
|
||||
if (testconst)
|
||||
errorset(sSETPOS,0);
|
||||
errorset(sSETPOS,0);
|
||||
} else if ((sym->usage & (uREAD | uSTOCK | uPUBLIC))==0) {
|
||||
errorset(sSETPOS,sym->lnumber);
|
||||
error(204,sym->name); /* value assigned to symbol is never used */
|
||||
|
@ -33,6 +33,13 @@ set_tests_properties(reset_errline_gh_230 PROPERTIES PASS_REGULAR_EXPRESSION "\
|
||||
.*\\.pwn\\(4\\) : warning 204: symbol is assigned a value that is never used: \\\"x\\\"\
|
||||
")
|
||||
|
||||
add_compiler_test(unused_symbol_line_gh_252 ${CMAKE_CURRENT_SOURCE_DIR}/unused_symbol_line_gh_252.pwn)
|
||||
set_tests_properties(unused_symbol_line_gh_252 PROPERTIES PASS_REGULAR_EXPRESSION "\
|
||||
.*\\.pwn\\(4\\) : warning 203: symbol is never used: \\\"y\\\"
|
||||
.*\\.pwn\\(8\\) : warning 203: symbol is never used: \\\"z\\\"
|
||||
.*\\.pwn\\(1\\) : warning 203: symbol is never used: \\\"x\\\"
|
||||
")
|
||||
|
||||
# Crashers
|
||||
#
|
||||
# These tests simply check that the compiler doesn't crash.
|
||||
|
9
source/compiler/tests/unused_symbol_line_gh_252.pwn
Normal file
9
source/compiler/tests/unused_symbol_line_gh_252.pwn
Normal file
@ -0,0 +1,9 @@
|
||||
new x;
|
||||
|
||||
main() {
|
||||
new y;
|
||||
f(0);
|
||||
}
|
||||
|
||||
f(z) {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user