X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/3e75a2c92b12766add442d00a86d5ec1c67ce560..3eb4f1a3e62807125a815dc572da9204b5b51865:/tests/named-refs.at?ds=sidebyside diff --git a/tests/named-refs.at b/tests/named-refs.at index 0b2f4c94..f9e48a57 100644 --- a/tests/named-refs.at +++ b/tests/named-refs.at @@ -19,7 +19,7 @@ AT_BANNER([[Named references tests.]]) AT_SETUP([Tutorial calculator]) - +AT_BISON_OPTION_PUSHDEFS AT_DATA_GRAMMAR([test.y], [[ %{ @@ -33,8 +33,8 @@ FILE *input; static semantic_value global_result = 0; static int global_count = 0; static int power (int base, int exponent); -static void yyerror (const char *s); -int yylex (void); +]AT_YYERROR_DECLARE[ +]AT_YYLEX_DECLARE[ %} %union @@ -83,12 +83,7 @@ exp: | '-' error { $$ = 0; YYERROR; } ; %% - -static void yyerror (const char *s) -{ - fprintf (stderr, "%s\n", s); -} - +]AT_YYERROR_DEFINE[ static int get_char (void) { int res = getc (input); @@ -119,7 +114,8 @@ static int read_signed_integer (void) return sign * n; } -int yylex (void) +static int +yylex (void) { int c; /* Skip white space. */ @@ -166,10 +162,8 @@ int main (int argc, const char **argv) } status = yyparse (); fclose (input); - if (global_result != result) - abort (); - if (global_count != count) - abort (); + assert (global_result == result); + assert (global_count == count); return status; } ]]) @@ -190,6 +184,7 @@ AT_DATA([input.txt], AT_BISON_CHECK([-o test.c test.y]) AT_COMPILE([[test]]) AT_PARSER_CHECK([./test input.txt], 0, [], [stderr]) +AT_BISON_OPTION_POPDEFS AT_CLEANUP @@ -198,13 +193,13 @@ AT_CLEANUP AT_SETUP([Undefined and ambiguous references]) - +AT_BISON_OPTION_PUSHDEFS AT_DATA_GRAMMAR([test.y], [[ %{ static int power (int base, int exponent); -static void yyerror (const char *s); -int yylex (void); +]AT_YYERROR_DECLARE[ +]AT_YYLEX_DECLARE[ %} %union @@ -258,16 +253,17 @@ exp: AT_BISON_CHECK([-o test.c test.y], 1, [], [[test.y:50.51-60: invalid reference: '$lo9' test.y:50.3-68: symbol not found in production: lo9 -test.y:51.51-60: warning: misleading reference: '$exp' -test.y:42.1-3: warning: refers to: $exp at $$ -test.y:51.7: warning: possibly meant: $x, hiding $exp at $1 -test.y:51.41: warning: possibly meant: $r, hiding $exp at $4 +test.y:51.51-60: warning: misleading reference: '$exp' [-Wother] +test.y:42.1-3: warning: refers to: $exp at $$ [-Wother] +test.y:51.7: warning: possibly meant: $x, hiding $exp at $1 [-Wother] +test.y:51.41: warning: possibly meant: $r, hiding $exp at $4 [-Wother] test.y:52.51-52: $l of 'exp' has no declared type test.y:55.46-49: invalid reference: '$r12' test.y:55.3-53: symbol not found in production: r12 test.y:56.29-33: invalid reference: '$expo' test.y:56.3-46: symbol not found in production: expo ]]) +AT_BISON_OPTION_POPDEFS AT_CLEANUP ####################################################################### @@ -281,9 +277,9 @@ foo: '1' foo.bar: '2' ]]) AT_BISON_CHECK([-o test.c test.y], 0, [], -[[test.y:11.22-29: warning: misleading reference: '$foo.bar' -test.y:11.8-10: warning: refers to: $foo at $1 -test.y:11.12-18: warning: possibly meant: $[foo.bar] at $2 +[[test.y:11.22-29: warning: misleading reference: '$foo.bar' [-Wother] +test.y:11.8-10: warning: refers to: $foo at $1 [-Wother] +test.y:11.12-18: warning: possibly meant: $[foo.bar] at $2 [-Wother] ]]) AT_CLEANUP @@ -577,7 +573,7 @@ start: ; ]]) AT_BISON_CHECK([[test.y]], [[0]], [], -[[test.y:4.9: warning: stray '$' -test.y:5.9: warning: stray '@' +[[test.y:4.9: warning: stray '$' [-Wother] +test.y:5.9: warning: stray '@' [-Wother] ]]) AT_CLEANUP