X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/68f91d58f15abe21c65a8b4d7022ccb854c857dc..5407fc7d76bc0c1d15b0e281ba12ea20c77751e7:/tests/named-refs.at diff --git a/tests/named-refs.at b/tests/named-refs.at index 12e726bc..1b76c800 100644 --- a/tests/named-refs.at +++ b/tests/named-refs.at @@ -46,10 +46,10 @@ static int power (int base, int exponent); %token NUM "number" %type exp -%nonassoc '=' /* comparison */ +%nonassoc '=' /* comparison */ %left '-' '+' %left '*' '/' -%left NEG /* negation--unary minus */ +%precedence NEG /* negation--unary minus */ %right '^' /* exponentiation */ %% @@ -69,7 +69,7 @@ exp: { if ($l != $r) fprintf (stderr, "calc: error: %d != %d\n", $l, $r); - $$ = $l; + $$ = $l; } | exp[x] '+' { $$ = $x; } [l] exp[r] { $$ = $l + $r; } | exp[l] '-' exp[r] { $$ = $l - $r; } @@ -181,15 +181,16 @@ AT_DATA([input.txt], (2^2)^3 = 64 ]]) -AT_BISON_CHECK([-o test.c test.y]) -AT_COMPILE([[test]]) +AT_FULL_COMPILE([[test]]) AT_PARSER_CHECK([./test input.txt], 0, [], [stderr]) AT_BISON_OPTION_POPDEFS AT_CLEANUP -####################################################################### +## ------------------------------------ ## +## Undefined and ambiguous references. ## +## ------------------------------------ ## AT_SETUP([Undefined and ambiguous references]) @@ -211,10 +212,10 @@ static int power (int base, int exponent); %token NUM "number" %type exp -%nonassoc '=' /* comparison */ +%nonassoc '=' /* comparison */ %left '-' '+' %left '*' '/' -%left NEG /* negation--unary minus */ +%precedence NEG /* negation--unary minus */ %right '^' /* exponentiation */ %% @@ -234,7 +235,7 @@ exp: { if ($l != $r) fprintf (stderr, "calc: error: %d != %d\n", $l, $r); - $$ = $l; + $$ = $l; } | exp[x] '+' { $$ = $x; } [l] exp[r] { $$ = $lo9 + $r; } | exp[x] '-' { $$ = $x; } [l] exp[r] { $$ = $exp - $r; } @@ -250,23 +251,48 @@ exp: %% ]]) -AT_BISON_CHECK([-o test.c test.y], 1, [], -[[test.y:50.51-60: error: 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: refers to: $exp at $$ -test.y:51.7: possibly meant: $x, hiding $exp at $1 -test.y:51.41: possibly meant: $r, hiding $exp at $4 -test.y:52.51-52: error: $l of 'exp' has no declared type -test.y:55.40-43: error: invalid reference: '$r12' -test.y:55.3-47: symbol not found in production: r12 -test.y:56.29-33: error: invalid reference: '$expo' -test.y:56.3-46: symbol not found in production: expo +AT_BISON_CHECK([-fcaret -o test.c test.y], 1, [], +[[test.y:52.51-60: error: invalid reference: '$lo9' + | exp[x] '+' { $$ = $x; } [l] exp[r] { $$ = $lo9 + $r; } + ^^^^^^^^^^ +test.y:52.3-68: symbol not found in production: lo9 + | exp[x] '+' { $$ = $x; } [l] exp[r] { $$ = $lo9 + $r; } + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +test.y:53.51-60: warning: misleading reference: '$exp' [-Wother] + | exp[x] '-' { $$ = $x; } [l] exp[r] { $$ = $exp - $r; } + ^^^^^^^^^^ +test.y:44.1-3: refers to: $exp at $$ + exp: + ^^^ +test.y:53.7: possibly meant: $x, hiding $exp at $1 + | exp[x] '-' { $$ = $x; } [l] exp[r] { $$ = $exp - $r; } + ^ +test.y:53.41: possibly meant: $r, hiding $exp at $4 + | exp[x] '-' { $$ = $x; } [l] exp[r] { $$ = $exp - $r; } + ^ +test.y:54.51-52: error: $l of 'exp' has no declared type + | exp[x] '*' { $$ = $x; } [l] exp[r] { $$ = $l * $r; } + ^^ +test.y:57.40-43: error: invalid reference: '$r12' + | exp[l] '^' exp[r] { $$ = power ($l, $r12); } + ^^^^ +test.y:57.3-47: symbol not found in production: r12 + | exp[l] '^' exp[r] { $$ = power ($l, $r12); } + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +test.y:58.29-33: error: invalid reference: '$expo' + | '(' exp ')' { $$ = $expo; } + ^^^^^ +test.y:58.3-46: symbol not found in production: expo + | '(' exp ')' { $$ = $expo; } + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ]]) AT_BISON_OPTION_POPDEFS AT_CLEANUP -####################################################################### + +## ----------------------- ## +## Misleading references. ## +## ----------------------- ## AT_SETUP([Misleading references]) AT_DATA_GRAMMAR([test.y], @@ -277,7 +303,7 @@ 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.22-29: warning: misleading reference: '$foo.bar' [-Wother] test.y:11.8-10: refers to: $foo at $1 test.y:11.12-18: possibly meant: $[foo.bar] at $2 ]]) @@ -694,7 +720,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