mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 12:53:03 +00:00
diagnostics: improve the accuracy for %error-verbose
Avoid duplicate warnings about %error-verbose, once for deprecation, another for duplicate. Keep only the duplicate warning for the second occurrence of %error-verbose. This will help removal fixits. * src/scan-gram.l (%error-verbose): Return as a PERCENT_ERROR_VERBOSE token. * src/parse-gram.y (do_error_verbose): New. Use it. * src/muscle-tab.c (muscle_percent_variable_update): Handle pseudo variables such as %error-verbose.
This commit is contained in:
@@ -446,6 +446,8 @@ muscle_percent_variable_update (char const *variable,
|
||||
} conversion_type;
|
||||
const conversion_type conversion[] =
|
||||
{
|
||||
{ "%error-verbose", "parse.error=verbose", muscle_keyword },
|
||||
{ "%error_verbose", "parse.error=verbose", muscle_keyword },
|
||||
{ "abstract", "api.parser.abstract", muscle_keyword },
|
||||
{ "annotations", "api.parser.annotations", muscle_code },
|
||||
{ "api.push_pull", "api.push-pull", muscle_keyword },
|
||||
@@ -477,7 +479,9 @@ muscle_percent_variable_update (char const *variable,
|
||||
: STREQ (c->obsolete, variable))
|
||||
{
|
||||
/* Generate the deprecation warning. */
|
||||
*old = define_directive (c->obsolete, kind, *value);
|
||||
*old = c->obsolete[0] == '%'
|
||||
? xstrdup (c->obsolete)
|
||||
: define_directive (c->obsolete, kind, *value);
|
||||
*upd = define_directive (c->updated, c->kind, *value);
|
||||
/* Update the variable and its value. */
|
||||
{
|
||||
|
||||
@@ -82,6 +82,9 @@
|
||||
string from the scanner (should be CODE). */
|
||||
static char const *translate_code_braceless (char *code, location loc);
|
||||
|
||||
/* Handle a %error-verbose directive. */
|
||||
static void do_error_verbose (location const *loc, char const *directive);
|
||||
|
||||
/* Handle a %name-prefix directive. */
|
||||
static void do_name_prefix (location const *loc,
|
||||
char const *directive, char const *value);
|
||||
@@ -151,6 +154,7 @@
|
||||
PERCENT_DEFAULT_PREC "%default-prec"
|
||||
PERCENT_DEFINE "%define"
|
||||
PERCENT_DEFINES "%defines"
|
||||
PERCENT_ERROR_VERBOSE "%error-verbose"
|
||||
PERCENT_EXPECT "%expect"
|
||||
PERCENT_EXPECT_RR "%expect-rr"
|
||||
PERCENT_FLAG "%<flag>"
|
||||
@@ -196,7 +200,8 @@
|
||||
%printer { fprintf (yyo, "{\n%s\n}", $$); } <char*>
|
||||
|
||||
%type <uniqstr>
|
||||
BRACKETED_ID ID ID_COLON PERCENT_FLAG PERCENT_NAME_PREFIX TAG
|
||||
BRACKETED_ID ID ID_COLON
|
||||
PERCENT_ERROR_VERBOSE PERCENT_FLAG PERCENT_NAME_PREFIX TAG
|
||||
tag tag.opt variable
|
||||
%printer { fputs ($$, yyo); } <uniqstr>
|
||||
%printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID
|
||||
@@ -300,6 +305,7 @@ prologue_declaration:
|
||||
defines_flag = true;
|
||||
spec_defines_file = xstrdup ($2);
|
||||
}
|
||||
| "%error-verbose" { do_error_verbose (&@$, $1); }
|
||||
| "%expect" INT { expected_sr_conflicts = $2; }
|
||||
| "%expect-rr" INT { expected_rr_conflicts = $2; }
|
||||
| "%file-prefix" STRING { spec_file_prefix = $2; }
|
||||
@@ -853,6 +859,15 @@ add_param (param_type type, char *decl, location loc)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
do_error_verbose (location const *loc, char const *directive)
|
||||
{
|
||||
bison_directive (loc, directive);
|
||||
muscle_percent_define_insert (directive, *loc, muscle_keyword, "",
|
||||
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
do_name_prefix (location const *loc,
|
||||
char const *directive, char const *value)
|
||||
|
||||
@@ -263,7 +263,7 @@ eqopt ({sp}=)?
|
||||
|
||||
/* Deprecated since Bison 3.0 (2013-07-25), but the warning is
|
||||
issued only since Bison 3.3. */
|
||||
"%error-verbose" DEPRECATED ("%define parse.error verbose");
|
||||
"%error-verbose" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext));
|
||||
|
||||
/* Deprecated since Bison 2.6 (2012-07-19), but the warning is
|
||||
issued only since Bison 3.3. */
|
||||
@@ -271,7 +271,7 @@ eqopt ({sp}=)?
|
||||
|
||||
/* Deprecated since Bison 2.7.90, 2012. */
|
||||
"%default"[-_]"prec" DEPRECATED ("%default-prec");
|
||||
"%error"[-_]"verbose" DEPRECATED ("%define parse.error verbose");
|
||||
"%error"[-_]"verbose" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext));
|
||||
"%expect"[-_]"rr" DEPRECATED ("%expect-rr");
|
||||
"%file-prefix"{eqopt} DEPRECATED ("%file-prefix");
|
||||
"%fixed"[-_]"output"[-_]"files" DEPRECATED ("%fixed-output-files");
|
||||
|
||||
@@ -2537,10 +2537,8 @@ input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parse
|
||||
fix-it:"input.y":{25:1-25:13}:"%pure-parser"
|
||||
input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated]
|
||||
fix-it:"input.y":{26:1-26:13}:"%token-table"
|
||||
input.y:27.1-14: warning: deprecated directive: '%error-verbose', use '%define parse.error verbose' [-Wdeprecated]
|
||||
fix-it:"input.y":{27:1-27:15}:"%define parse.error verbose"
|
||||
input.y:27-14: error: %define variable 'parse.error' redefined
|
||||
input.y:11-14: previous definition
|
||||
input.y:27.1-14: error: %define variable 'parse.error' redefined
|
||||
input.y:11.1-14: previous definition
|
||||
input.y:29.1-18: warning: deprecated directive: '%name-prefix "bar"', use '%define api.prefix {bar}' [-Wdeprecated]
|
||||
fix-it:"input.y":{29:1-29:19}:"%define api.prefix {bar}"
|
||||
]])
|
||||
@@ -2587,7 +2585,7 @@ AT_CHECK([cat input.y], [],
|
||||
%output "foo"
|
||||
%pure-parser
|
||||
%token-table
|
||||
%define parse.error verbose
|
||||
%error-verbose
|
||||
%glr-parser
|
||||
%define api.prefix {bar}
|
||||
%%
|
||||
@@ -2597,9 +2595,9 @@ exp : '0'
|
||||
# Unfortunately so far we don't remove duplicate definitions,
|
||||
# so there are still warnings.
|
||||
AT_BISON_CHECK([[-fcaret input.y]], [[1]], [],
|
||||
[[input.y:26.1-27: error: %define variable 'parse.error' redefined
|
||||
%define parse.error verbose
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
[[input.y:26.1-14: error: %define variable 'parse.error' redefined
|
||||
%error-verbose
|
||||
^~~~~~~~~~~~~~
|
||||
input.y:11.1-27: previous definition
|
||||
%define parse.error verbose
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -2642,12 +2640,10 @@ AT_BISON_CHECK([[input.y]], [[1]], [[]],
|
||||
input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
|
||||
input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
|
||||
input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
|
||||
input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
|
||||
input.y:13.3-29: error: %define variable 'parse.error' redefined
|
||||
input.y:13-14: previous definition
|
||||
input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
|
||||
input.y:14.3-29: error: %define variable 'parse.error' redefined
|
||||
input.y:13.3-29: previous definition
|
||||
input.y:13.16-29: error: %define variable 'parse.error' redefined
|
||||
input.y:13.1-14: previous definition
|
||||
input.y:14.16-29: error: %define variable 'parse.error' redefined
|
||||
input.y:13.16-29: previous definition
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
Reference in New Issue
Block a user