[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
diagnostics: remove redundancy
From: |
Akim Demaille |
Subject: |
diagnostics: remove redundancy |
Date: |
Tue, 22 Jan 2019 06:33:48 +0100 |
commit 27104acdbee1e234c5d88eb139509e2fb57071d7
Author: Akim Demaille <address@hidden>
Date: Mon Jan 21 20:03:19 2019 +0100
diagnostics: remove redundancy
Don't repeat the name of the warning in the sub messages. E.g.,
remove the second "[-Wother]" in the following message
foo.y:2.1-27: warning: %define variable 'parse.error' redefined
[-Wother]
%define parse.error verbose
^~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.y:1.1-27: previous definition [-Wother]
%define parse.error verbose
^~~~~~~~~~~~~~~~~~~~~~~~~~~
* src/complain.c (error_message): Don't print the warning type when
it's indented.
Adjust test cases.
diff --git a/src/complain.c b/src/complain.c
index c177e202..a4ab0a1f 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -279,15 +279,18 @@ error_message (const location *loc, warnings flags, const
char *prefix,
*indent_ptr = pos;
else if (*indent_ptr > pos)
fprintf (stderr, "%*s", *indent_ptr - pos, "");
- indent_ptr = 0;
+ indent_ptr = NULL;
}
if (prefix)
fprintf (stderr, "%s: ", prefix);
vfprintf (stderr, message, args);
- if (! (flags & silent))
+ /* Print the type of warning, only if this is not a sub message
+ (in which case the prefix is null). */
+ if (! (flags & silent) && prefix)
warnings_print_categories (flags, stderr);
+
{
size_t l = strlen (message);
if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ')
diff --git a/tests/input.at b/tests/input.at
index bce75b97..22bcfe87 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -2523,15 +2523,15 @@ fix-it:"input.y":{12:1-12:11}:"%expect-rr"
input.y:13.1-14: warning: deprecated directive: '%file-prefix =', use
'%file-prefix' [-Wdeprecated]
fix-it:"input.y":{13:1-13:15}:"%file-prefix"
input.y:14.1-16.5: warning: duplicate directive: '%file-prefix\n =' [-Wother]
-input.y:13.1-20: previous declaration [-Wother]
+input.y:13.1-20: previous declaration
fix-it:"input.y":{14:1-16:6}:""
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 [-Wother]
+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 [-Wother]
+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}"
@@ -2551,7 +2551,7 @@ input.y:27.1-14: error: %define variable 'parse.error'
redefined
input.y:11.1-14: previous definition
fix-it:"input.y":{27:1-27:15}:""
input.y:29.1-18: warning: duplicate directive: '%name-prefix "bar"' [-Wother]
-input.y:13.1-20: previous declaration [-Wother]
+input.y:13.1-20: previous declaration
fix-it:"input.y":{29:1-29:19}:""
input.y: warning: fix-its can be applied. Rerun with option '--update'.
[-Wother]
]])
@@ -2669,7 +2669,7 @@ AT_DATA_GRAMMAR([[input.y]],
AT_BISON_CHECK([[input.y]], [[0]], [[]],
[[input.y:14.1-15.5: warning: duplicate directive: '%file-prefix' [-Wother]
-input.y:13.1-18: previous declaration [-Wother]
+input.y:13.1-18: previous declaration
input.y: warning: %expect-rr applies only to GLR parsers [-Wother]
input.y: warning: fix-its can be applied. Rerun with option '--update'.
[-Wother]
]])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- diagnostics: remove redundancy,
Akim Demaille <=