parent
3ee21806d0
commit
3c6be803d7
@ -2856,10 +2856,9 @@ static void decl_const(int vclass)
|
|||||||
/* add_constant() checks for duplicate definitions */
|
/* add_constant() checks for duplicate definitions */
|
||||||
if (!matchtag(tag,exprtag,FALSE)) {
|
if (!matchtag(tag,exprtag,FALSE)) {
|
||||||
/* temporarily reset the line number to where the symbol was defined */
|
/* temporarily reset the line number to where the symbol was defined */
|
||||||
int orgfline=fline;
|
errorset(sSETPOS,symbolline);
|
||||||
fline=symbolline;
|
|
||||||
error(213); /* tagname mismatch */
|
error(213); /* tagname mismatch */
|
||||||
fline=orgfline;
|
errorset(sSETPOS,0);
|
||||||
} /* if */
|
} /* if */
|
||||||
sym=add_constant(constname,val,vclass,tag);
|
sym=add_constant(constname,val,vclass,tag);
|
||||||
if (sym!=NULL)
|
if (sym!=NULL)
|
||||||
@ -4781,6 +4780,7 @@ static int testsymbols(symbol *root,int level,int testlabs,int testconst)
|
|||||||
} else if ((sym->usage & uREAD)==0) {
|
} else if ((sym->usage & uREAD)==0) {
|
||||||
errorset(sSETPOS,sym->lnumber);
|
errorset(sSETPOS,sym->lnumber);
|
||||||
error(203,sym->name); /* symbol isn't used: ... */
|
error(203,sym->name); /* symbol isn't used: ... */
|
||||||
|
errorset(sSETPOS,0);
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* if */
|
} /* if */
|
||||||
break;
|
break;
|
||||||
@ -4800,6 +4800,7 @@ static int testsymbols(symbol *root,int level,int testlabs,int testconst)
|
|||||||
if (testconst && (sym->usage & uREAD)==0) {
|
if (testconst && (sym->usage & uREAD)==0) {
|
||||||
errorset(sSETPOS,sym->lnumber);
|
errorset(sSETPOS,sym->lnumber);
|
||||||
error(203,sym->name); /* symbol isn't used: ... */
|
error(203,sym->name); /* symbol isn't used: ... */
|
||||||
|
errorset(sSETPOS,0);
|
||||||
} /* if */
|
} /* if */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -4810,13 +4811,17 @@ static int testsymbols(symbol *root,int level,int testlabs,int testconst)
|
|||||||
if (testconst)
|
if (testconst)
|
||||||
errorset(sSETPOS,sym->lnumber);
|
errorset(sSETPOS,sym->lnumber);
|
||||||
error(203,sym->name,sym->lnumber); /* symbol isn't used (and not stock) */
|
error(203,sym->name,sym->lnumber); /* symbol isn't used (and not stock) */
|
||||||
|
if (testconst)
|
||||||
|
errorset(sSETPOS,0);
|
||||||
} else if ((sym->usage & (uREAD | uSTOCK | uPUBLIC))==0) {
|
} else if ((sym->usage & (uREAD | uSTOCK | uPUBLIC))==0) {
|
||||||
errorset(sSETPOS,sym->lnumber);
|
errorset(sSETPOS,sym->lnumber);
|
||||||
error(204,sym->name); /* value assigned to symbol is never used */
|
error(204,sym->name); /* value assigned to symbol is never used */
|
||||||
|
errorset(sSETPOS,0);
|
||||||
#if 0 // ??? not sure whether it is a good idea to force people use "const"
|
#if 0 // ??? not sure whether it is a good idea to force people use "const"
|
||||||
} else if ((sym->usage & (uWRITTEN | uPUBLIC | uCONST))==0 && sym->ident==iREFARRAY) {
|
} else if ((sym->usage & (uWRITTEN | uPUBLIC | uCONST))==0 && sym->ident==iREFARRAY) {
|
||||||
errorset(sSETPOS,sym->lnumber);
|
errorset(sSETPOS,sym->lnumber);
|
||||||
error(214,sym->name); /* make array argument "const" */
|
error(214,sym->name); /* make array argument "const" */
|
||||||
|
errorset(sSETPOS,0);
|
||||||
#endif
|
#endif
|
||||||
} /* if */
|
} /* if */
|
||||||
/* also mark the variable (local or global) to the debug information */
|
/* also mark the variable (local or global) to the debug information */
|
||||||
|
@ -10,27 +10,34 @@ function(add_compiler_test test_name options)
|
|||||||
ENVIRONMENT PATH=$<TARGET_FILE_DIR:pawnc>)
|
ENVIRONMENT PATH=$<TARGET_FILE_DIR:pawnc>)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
#
|
|
||||||
# Compile tests
|
# Compile tests
|
||||||
#
|
#
|
||||||
# These tests compare compile output against a regular expression and fail if the output
|
# These tests compare compile output against a regular expression and fail if the output
|
||||||
# doesn't match the expected pattern.
|
# doesn't match the expected pattern.
|
||||||
#
|
|
||||||
add_compiler_test(gh_217 ${CMAKE_CURRENT_SOURCE_DIR}/gh_217.pwn)
|
|
||||||
set_tests_properties(gh_217 PROPERTIES PASS_REGULAR_EXPRESSION
|
|
||||||
".*: warning 237: user warning: this is warning 1[\r\n]+\
|
|
||||||
.*: warning 237: user warning: this iswarning 2[\r\n]+\
|
|
||||||
.*: warning 237: user warning: this is warning 3[\r\n]+\
|
|
||||||
.*: warning 237: user warning: this is warning 4[\r\n]+\
|
|
||||||
.*: warning 234: function is deprecated \\(symbol \"f\"\\) don't use this functionplease[\r\n]+\
|
|
||||||
.*: warning 234: function is deprecated \\(symbol \"f\"\\) don't use this functionplease")
|
|
||||||
|
|
||||||
#
|
add_compiler_test(gh_217 ${CMAKE_CURRENT_SOURCE_DIR}/gh_217.pwn)
|
||||||
|
set_tests_properties(gh_217 PROPERTIES PASS_REGULAR_EXPRESSION "\
|
||||||
|
.*\\.pwn\\(11\\) : warning 237: user warning: this is warning 1\
|
||||||
|
.*\\.pwn\\(13\\) : warning 237: user warning: this iswarning 2\
|
||||||
|
.*\\.pwn\\(15\\) : warning 237: user warning: this is warning 3\
|
||||||
|
.*\\.pwn\\(17\\) : warning 237: user warning: this is warning 4\
|
||||||
|
.*\\.pwn\\(27\\) : warning 234: function is deprecated \\(symbol \"f\"\\) don't use this functionplease\
|
||||||
|
.*\\.pwn\\(32\\) : warning 234: function is deprecated \\(symbol \"f\"\\) don't use this functionplease\
|
||||||
|
")
|
||||||
|
|
||||||
|
add_compiler_test(reset_errline_gh_230 ${CMAKE_CURRENT_SOURCE_DIR}/reset_errline_gh_230.pwn)
|
||||||
|
set_tests_properties(reset_errline_gh_230 PROPERTIES PASS_REGULAR_EXPRESSION "\
|
||||||
|
.*\\.pwn\\(2\\) : error 017: undefined symbol \\\"undefined\\\"\
|
||||||
|
.*\\.pwn\\(2\\) : warning 215: expression has no effect\
|
||||||
|
.*\\.pwn\\(7\\) : warning 204: symbol is assigned a value that is never used: \\\"y\\\"\
|
||||||
|
.*\\.pwn\\(4\\) : warning 204: symbol is assigned a value that is never used: \\\"x\\\"\
|
||||||
|
")
|
||||||
|
|
||||||
# Crashers
|
# Crashers
|
||||||
#
|
#
|
||||||
# These tests simply check that the compiler doesn't crash.
|
# These tests simply check that the compiler doesn't crash.
|
||||||
#
|
#
|
||||||
# TODO: Probably need to support tests that exist with a non-zero code but don't crash?
|
# TODO: Probably need to support tests that exist with a non-zero code but don't crash?
|
||||||
# Right now this will cause a failure.
|
# Right now this will cause a failure.
|
||||||
#
|
|
||||||
add_compiler_test(md_array_crash_gh_220 ${CMAKE_CURRENT_SOURCE_DIR}/md_array_crash_gh_220.pwn)
|
add_compiler_test(md_array_crash_gh_220 ${CMAKE_CURRENT_SOURCE_DIR}/md_array_crash_gh_220.pwn)
|
||||||
|
8
source/compiler/tests/reset_errline_gh_230.pwn
Normal file
8
source/compiler/tests/reset_errline_gh_230.pwn
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
main() {
|
||||||
|
undefined;
|
||||||
|
|
||||||
|
new x = 0;
|
||||||
|
|
||||||
|
new y;
|
||||||
|
y = 123;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user