summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2019-01-16 08:29:03 +0100
committerAkim Demaille <akim.demaille@gmail.com>2019-01-16 08:40:47 +0100
commitb44393299120b9c8f7cb490e778a869dcbd7b7f9 (patch)
tree2d1b2eebb608f817053d6262bd4ca355ed60610a
parentf5a646c39055e8ac823377a407404a3ff604df08 (diff)
downloadbison-b44393299120b9c8f7cb490e778a869dcbd7b7f9.tar.gz
diagnostics: properly indent the "previous declaration" message
* src/complain.c (duplicate_directive, duplicate_rule_directive): Here.
-rw-r--r--src/complain.c12
-rw-r--r--tests/actions.at2
-rw-r--r--tests/input.at4
3 files changed, 10 insertions, 8 deletions
diff --git a/src/complain.c b/src/complain.c
index 6b6b2c0b..813a442d 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -403,11 +403,12 @@ void
duplicate_directive (char const *directive,
location first, location second)
{
+ unsigned i = 0;
if (feature_flag & feature_caret)
- complain (&second, Wother, _("duplicate directive"));
+ complain_indent (&second, Wother, &i, _("duplicate directive"));
else
- complain (&second, Wother, _("duplicate directive: %s"), directive);
- unsigned i = SUB_INDENT;
+ complain_indent (&second, Wother, &i, _("duplicate directive: %s"), directive);
+ i += SUB_INDENT;
complain_indent (&first, complaint, &i, _("previous declaration"));
fixits_register (&second, "");
}
@@ -416,7 +417,8 @@ void
duplicate_rule_directive (char const *directive,
location first, location second)
{
- complain (&second, complaint, _("only one %s allowed per rule"), directive);
- unsigned i = SUB_INDENT;
+ unsigned i = 0;
+ complain_indent (&second, complaint, &i, _("only one %s allowed per rule"), directive);
+ i += SUB_INDENT;
complain_indent (&first, complaint, &i, _("previous declaration"));
}
diff --git a/tests/actions.at b/tests/actions.at
index 787435e3..e5654a47 100644
--- a/tests/actions.at
+++ b/tests/actions.at
@@ -171,7 +171,7 @@ AT_BISON_CHECK([-fcaret one.y], [1], [],
[[one.y:11.13-18: error: only one %empty allowed per rule
%empty {} %empty
^~~~~~
-one.y:11.3-8: previous declaration
+one.y:11.3-8: previous declaration
%empty {} %empty
^~~~~~
]])
diff --git a/tests/input.at b/tests/input.at
index 3314d680..39294bf6 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -2527,10 +2527,10 @@ fix-it:"input.y":{14:1-15:3}:"%file-prefix"
input.y:17.1-19: warning: deprecated directive: '%fixed-output_files', use '%fixed-output-files' [-Wdeprecated]
fix-it:"input.y":{17:1-17:20}:"%fixed-output-files"
input.y:18.1-19: warning: duplicate directive: %fixed_output-files [-Wother]
-input.y:17.1-19: previous declaration
+input.y:17.1-19: previous declaration
fix-it:"input.y":{18:1-18:20}:""
input.y:19.1-19: warning: duplicate directive: %fixed-output-files [-Wother]
-input.y:17.1-19: previous declaration
+input.y:17.1-19: previous declaration
fix-it:"input.y":{19:1-19:20}:""
input.y:20.1-19: warning: deprecated directive: '%name-prefix= "foo"', use '%define api.prefix {foo}' [-Wdeprecated]
fix-it:"input.y":{20:1-20:20}:"%define api.prefix {foo}"