mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 04:43:03 +00:00
diagnostics: add fixit support for duplicate removal
* src/muscle-tab.c (muscle_percent_define_insert): Register a fixit for duplicate removal. * tests/input.at: Adjust expectations.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "complain.h"
|
||||
#include "files.h"
|
||||
#include "fixits.h"
|
||||
#include "getargs.h"
|
||||
#include "muscle-tab.h"
|
||||
#include "quote.h"
|
||||
@@ -532,6 +533,7 @@ muscle_percent_define_insert (char const *var, location variable_loc,
|
||||
i += SUB_INDENT;
|
||||
location loc = muscle_percent_define_get_loc (variable);
|
||||
complain_indent (&loc, complaint, &i, _("previous definition"));
|
||||
fixits_register (&variable_loc, "");
|
||||
warned = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2539,6 +2539,7 @@ input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-tabl
|
||||
fix-it:"input.y":{26:1-26:13}:"%token-table"
|
||||
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: deprecated directive: '%name-prefix "bar"', use '%define api.prefix {bar}' [-Wdeprecated]
|
||||
fix-it:"input.y":{29:1-29:19}:"%define api.prefix {bar}"
|
||||
]])
|
||||
@@ -2585,23 +2586,15 @@ AT_CHECK([cat input.y], [],
|
||||
%output "foo"
|
||||
%pure-parser
|
||||
%token-table
|
||||
%error-verbose
|
||||
|
||||
%glr-parser
|
||||
%define api.prefix {bar}
|
||||
%%
|
||||
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-14: error: %define variable 'parse.error' redefined
|
||||
%error-verbose
|
||||
^~~~~~~~~~~~~~
|
||||
input.y:11.1-27: previous definition
|
||||
%define parse.error verbose
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
input.y:28.1-24: error: %define variable 'api.prefix' redefined
|
||||
[[input.y:28.1-24: error: %define variable 'api.prefix' redefined
|
||||
%define api.prefix {bar}
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~
|
||||
input.y:19.1-24: previous definition
|
||||
|
||||
Reference in New Issue
Block a user