summaryrefslogtreecommitdiff
path: root/tests/existing.at
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2019-04-24 08:04:43 +0200
committerAkim Demaille <akim.demaille@gmail.com>2019-04-24 13:08:51 +0200
commit935d119c82f018a135b424ced986e20299a0db14 (patch)
treeaa99664e580cb78268445e774461957e12b27108 /tests/existing.at
parent01fe32ee5380010748a383e77eb05baf0c0f9bdc (diff)
downloadbison-935d119c82f018a135b424ced986e20299a0db14.tar.gz
diagnostics: better rule locations
The "identifier and colon" of a rule is implemented as a single token, but whose location is only that of the identifier (so that messages about the lhs of a rule are accurate). When reducing empty rules, the default location is the single point location on the end of the previous symbol. As a consequence, when Bison parses a grammar, the location of the right-hand side of an empty rule is based on the lhs, *independently of the position of the colon*. And the colon can be way farther, separated by comments, white spaces, including empty lines. As a result, some messages look really bad. For instance: $ cat foo.y %% foo : /* empty */ bar : /* empty */ gives $ bison -Wall foo.y foo.y:2.4: warning: empty rule without %empty [-Wempty-rule] 2 | foo : /* empty */ | ^ foo.y:3.4: warning: empty rule without %empty [-Wempty-rule] 3 | bar | ^ The carets are not at the right column, not even the right line. This commit passes the colon "again" after the "id colon" token, which gives more accurate locations for these messages: $ bison -Wall foo.y foo.y:2.10: warning: empty rule without %empty [-Wempty-rule] 2 | foo : /* empty */ | ^ foo.y:4.2: warning: empty rule without %empty [-Wempty-rule] 4 | : /* empty */ | ^ * src/scan-gram.l (SC_AFTER_IDENTIFIER): Rollback the colon, so that we scan it again afterwards. (INITIAL): Scan colons. * src/parse-gram.y (COLON): New. (rules): Parse the colon after the rule's id_colon (and possible named reference). * tests/actions.at, tests/conflicts.at, tests/diagnostics.at, * tests/existing.at: Adjust.
Diffstat (limited to 'tests/existing.at')
-rw-r--r--tests/existing.at68
1 files changed, 34 insertions, 34 deletions
diff --git a/tests/existing.at b/tests/existing.at
index 27bd0be3..782633ad 100644
--- a/tests/existing.at
+++ b/tests/existing.at
@@ -427,15 +427,15 @@ dnl don't like even 'print $!4;'.
dnl BISON-STDERR
[[input.y:66.10: warning: empty rule without %empty [-Wempty-rule]
-input.y:169.8: warning: empty rule without %empty [-Wempty-rule]
-input.y:174.12: warning: empty rule without %empty [-Wempty-rule]
-input.y:179.13: warning: empty rule without %empty [-Wempty-rule]
-input.y:187.15: warning: empty rule without %empty [-Wempty-rule]
-input.y:201.8: warning: empty rule without %empty [-Wempty-rule]
-input.y:206.21: warning: empty rule without %empty [-Wempty-rule]
-input.y:220.20: warning: empty rule without %empty [-Wempty-rule]
-input.y:299.13: warning: empty rule without %empty [-Wempty-rule]
-input.y:322.9: warning: empty rule without %empty [-Wempty-rule]
+input.y:170.10: warning: empty rule without %empty [-Wempty-rule]
+input.y:175.10: warning: empty rule without %empty [-Wempty-rule]
+input.y:180.10: warning: empty rule without %empty [-Wempty-rule]
+input.y:188.10: warning: empty rule without %empty [-Wempty-rule]
+input.y:202.10: warning: empty rule without %empty [-Wempty-rule]
+input.y:207.10: warning: empty rule without %empty [-Wempty-rule]
+input.y:221.10: warning: empty rule without %empty [-Wempty-rule]
+input.y:300.10: warning: empty rule without %empty [-Wempty-rule]
+input.y:323.10: warning: empty rule without %empty [-Wempty-rule]
]AT_COND_CASE([[canonical LR]],
[[input.y: warning: 265 shift/reduce conflicts [-Wconflicts-sr]]],
[[input.y: warning: 65 shift/reduce conflicts [-Wconflicts-sr]]])[
@@ -1395,28 +1395,28 @@ dnl INPUT
[[]],
dnl BISON-STDERR
-[[input.y:128.12: warning: empty rule without %empty [-Wempty-rule]
-input.y:137.10: warning: empty rule without %empty [-Wempty-rule]
-input.y:142.8: warning: empty rule without %empty [-Wempty-rule]
-input.y:161.15: warning: empty rule without %empty [-Wempty-rule]
-input.y:179.17: warning: empty rule without %empty [-Wempty-rule]
-input.y:205.16: warning: empty rule without %empty [-Wempty-rule]
-input.y:213.9: warning: empty rule without %empty [-Wempty-rule]
-input.y:225.6: warning: empty rule without %empty [-Wempty-rule]
+[[input.y:128.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:137.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:142.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:161.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:179.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:205.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:213.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:225.18: warning: empty rule without %empty [-Wempty-rule]
input.y:292.18: warning: empty rule without %empty [-Wempty-rule]
-input.y:294.19: warning: empty rule without %empty [-Wempty-rule]
-input.y:367.16: warning: empty rule without %empty [-Wempty-rule]
-input.y:373.11: warning: empty rule without %empty [-Wempty-rule]
-input.y:387.15: warning: empty rule without %empty [-Wempty-rule]
+input.y:294.20: warning: empty rule without %empty [-Wempty-rule]
+input.y:367.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:373.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:387.18: warning: empty rule without %empty [-Wempty-rule]
input.y:401.18: warning: empty rule without %empty [-Wempty-rule]
-input.y:413.15: warning: empty rule without %empty [-Wempty-rule]
-input.y:443.15: warning: empty rule without %empty [-Wempty-rule]
-input.y:471.15: warning: empty rule without %empty [-Wempty-rule]
-input.y:474.15: warning: empty rule without %empty [-Wempty-rule]
-input.y:489.15: warning: empty rule without %empty [-Wempty-rule]
-input.y:506.14: warning: empty rule without %empty [-Wempty-rule]
-input.y:587.9: warning: empty rule without %empty [-Wempty-rule]
-input.y:591.14: warning: empty rule without %empty [-Wempty-rule]
+input.y:413.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:443.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:471.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:474.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:489.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:506.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:587.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:591.18: warning: empty rule without %empty [-Wempty-rule]
]AT_COND_CASE([[canonical LR]],
[[input.y: warning: 1876 shift/reduce conflicts [-Wconflicts-sr]
input.y: warning: 144 reduce/reduce conflicts [-Wconflicts-rr]]],
@@ -2009,11 +2009,11 @@ dnl without being followed by "of".)
[[VARIABLE, '=', LABEL, LEFT, DOT_X]],
dnl BISON-STDERR
-[[input.y:202.19: warning: empty rule without %empty [-Wempty-rule]
-input.y:270.6: warning: empty rule without %empty [-Wempty-rule]
-input.y:292.12: warning: empty rule without %empty [-Wempty-rule]
-input.y:309.17: warning: empty rule without %empty [-Wempty-rule]
-input.y:382.13: warning: empty rule without %empty [-Wempty-rule]
+[[input.y:202.20: warning: empty rule without %empty [-Wempty-rule]
+input.y:270.7: warning: empty rule without %empty [-Wempty-rule]
+input.y:292.13: warning: empty rule without %empty [-Wempty-rule]
+input.y:309.18: warning: empty rule without %empty [-Wempty-rule]
+input.y:382.14: warning: empty rule without %empty [-Wempty-rule]
input.y:471.11-48: warning: rule useless in parser due to conflicts [-Wother]
input.y:154.1-5: warning: useless associativity for LABEL, use %precedence [-Wprecedence]
input.y:156.1-5: warning: useless associativity for VARIABLE, use %precedence [-Wprecedence]