[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fixits: handle per-rule duplicates
From: |
Akim Demaille |
Subject: |
fixits: handle per-rule duplicates |
Date: |
Thu, 17 Jan 2019 18:17:27 +0100 |
commit 5879c8dc5a391ce3d9de68f50326121babc8d1be
Author: Akim Demaille <address@hidden>
Date: Thu Jan 17 06:44:51 2019 +0100
fixits: handle per-rule duplicates
* src/complain.c (duplicate_rule_directive): Here.
* tests/actions.at (Invalid uses of %empty): Check it.
diff --git a/src/complain.c b/src/complain.c
index d623bb45..82258c62 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -421,4 +421,5 @@ duplicate_rule_directive (char const *directive,
complain_indent (&second, complaint, &i, _("only one %s allowed per
rule"), directive);
i += SUB_INDENT;
complain_indent (&first, complaint, &i, _("previous declaration"));
+ fixits_register (&second, "");
}
diff --git a/tests/actions.at b/tests/actions.at
index e5654a47..aa1eb3aa 100644
--- a/tests/actions.at
+++ b/tests/actions.at
@@ -174,8 +174,35 @@ AT_BISON_CHECK([-fcaret one.y], [1], [],
one.y:11.3-8: previous declaration
%empty {} %empty
^~~~~~
+one.y: warning: fix-its can be applied. Rerun with option '--update'.
[-Wother]
]])
+AT_BISON_CHECK([-fcaret -u one.y], [1], [],
+[[one.y:11.13-18: error: only one %empty allowed per rule
+ %empty {} %empty
+ ^~~~~~
+one.y:11.3-8: previous declaration
+ %empty {} %empty
+ ^~~~~~
+bison: file 'one.y' was updated (backup: 'one.y~')
+]])
+
+AT_CHECK([cat one.y], [],
+[[%code top {
+/* Load config.h, and adjust to the compiler.
+ We used to do it here, but each time we add a new line,
+ we have to adjust all the line numbers in error messages.
+ It's simpler to use a constant include to a varying file. */
+#include <testsuite.h>
+}
+
+%%
+exp:
+ %empty {} @&t@
+;
+]])
+
+
AT_DATA_GRAMMAR([[two.y]],
[[%%
exp:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- fixits: handle per-rule duplicates,
Akim Demaille <=