[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/4] diagnostics: improve -fcaret for list of accepted values
From: |
Akim Demaille |
Subject: |
[PATCH 4/4] diagnostics: improve -fcaret for list of accepted values |
Date: |
Sun, 16 Dec 2012 15:19:41 +0100 |
Instead of
input.y:1.9-21: error: invalid value for %define variable 'api.push-pull':
'neither'
%define api.push_pull "neither"
^^^^^^^^^^^^^
input.y:1.9-21: accepted value: 'pull'
%define api.push_pull "neither"
^^^^^^^^^^^^^
input.y:1.9-21: accepted value: 'push'
%define api.push_pull "neither"
^^^^^^^^^^^^^
input.y:1.9-21: accepted value: 'both'
%define api.push_pull "neither"
^^^^^^^^^^^^^
report
input.y:1.9-21: error: invalid value for %define variable 'api.push-pull':
'neither'
%define api.push_pull "neither"
^^^^^^^^^^^^^
input.y:1.9-21: accepted value: 'pull'
input.y:1.9-21: accepted value: 'push'
input.y:1.9-21: accepted value: 'both'
* src/complain.h (no_caret): New.
* src/complain.c (error_message): Use it.
* src/muscle-tab.c (muscle_percent_define_check_values): Use it.
* src/scan-skel.l (flag): Ditto.
* tests/input.at: Adjust and check.
---
src/complain.c | 2 +-
src/complain.h | 1 +
src/muscle-tab.c | 4 ++--
src/scan-skel.l | 2 +-
tests/input.at | 12 ++++++++++++
5 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/complain.c b/src/complain.c
index ee1b4a1..984b136 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -114,7 +114,7 @@ error_message (const location *loc, warnings flags, const
char *prefix,
{
putc ('\n', stderr);
fflush (stderr);
- if (loc && feature_flag & feature_caret)
+ if (loc && feature_flag & feature_caret && !(flags & no_caret))
location_caret (stderr, *loc);
}
}
diff --git a/src/complain.h b/src/complain.h
index 56ddfa0..d715bb6 100644
--- a/src/complain.h
+++ b/src/complain.h
@@ -43,6 +43,7 @@ typedef enum
complaint = 1 << 11, /**< All complaints. */
fatal = 1 << 12, /**< All fatal errors. */
silent = 1 << 13, /**< Do not display the warning type. */
+ no_caret = 1 << 14, /**< Do not display caret location. */
/**< All above warnings. */
Wall = ~complaint & ~fatal & ~silent
diff --git a/src/muscle-tab.c b/src/muscle-tab.c
index f3933c3..7a11204 100644
--- a/src/muscle-tab.c
+++ b/src/muscle-tab.c
@@ -608,8 +608,8 @@ muscle_percent_define_check_values (char const * const
*values)
quote (*variablep), quote_n (1, value));
i += SUB_INDENT;
for (values = variablep + 1; *values; ++values)
- complain_indent (&loc, complaint, &i, _("accepted value: %s"),
- quote (*values));
+ complain_indent (&loc, complaint | no_caret, &i,
+ _("accepted value: %s"), quote (*values));
}
else
{
diff --git a/src/scan-skel.l b/src/scan-skel.l
index a0d9c9e..5d63541 100644
--- a/src/scan-skel.l
+++ b/src/scan-skel.l
@@ -186,7 +186,7 @@ flag (const char *arg)
else if (STREQ (arg, "fatal"))
return fatal;
else if (STREQ (arg, "note"))
- return silent | complaint;
+ return silent | complaint | no_caret;
else if (STREQ (arg, "warn"))
return Wother;
else
diff --git a/tests/input.at b/tests/input.at
index 5e5b1e8..a5d8d92 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -1343,6 +1343,18 @@ input.y:1.9-21: accepted value: 'push'
input.y:1.9-21: accepted value: 'both'
]])
+AT_BISON_CHECK([[-fcaret input.y]], [1], [],
+[[input.y:1.9-21: warning: deprecated %define variable name: 'api.push_pull',
use 'api.push-pull' [-Wdeprecated]
+ %define api.push_pull "neither"
+ ^^^^^^^^^^^^^
+input.y:1.9-21: error: invalid value for %define variable 'api.push-pull':
'neither'
+ %define api.push_pull "neither"
+ ^^^^^^^^^^^^^
+input.y:1.9-21: accepted value: 'pull'
+input.y:1.9-21: accepted value: 'push'
+input.y:1.9-21: accepted value: 'both'
+]])
+
AT_DATA([[input.y]],
[[%define lr.keep_unreachable_states maybe
%%
--
1.8.0.2