mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 13:23:04 +00:00
diagnostics: fix the order of multiple declarations reports
On
%token FOO "foo"
%printer {} "foo"
%printer {} FOO
we report
/tmp/foo.yy:2.10-11: error: %printer redeclaration for FOO
%printer {} "foo"
^^
/tmp/foo.yy:3.10-11: previous declaration
%printer {} FOO
^^
* src/symtab.c (locations_sort): New.
Use it.
* tests/input.at (Invalid Aliases): Stress the order of diagnostics.
This commit is contained in:
15
src/symtab.c
15
src/symtab.c
@@ -122,6 +122,19 @@ void symbols_sort (symbol **first, symbol **second)
|
||||
}
|
||||
}
|
||||
|
||||
/* Likewise, for locations. */
|
||||
|
||||
static
|
||||
void locations_sort (location *first, location *second)
|
||||
{
|
||||
if (0 < location_cmp (*first, *second))
|
||||
{
|
||||
location tmp = *first;
|
||||
*first = *second;
|
||||
*second = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
char const *
|
||||
code_props_type_string (code_props_type kind)
|
||||
{
|
||||
@@ -232,6 +245,7 @@ symbol_redeclaration (symbol *s, const char *what, location first,
|
||||
location second)
|
||||
{
|
||||
unsigned i = 0;
|
||||
locations_sort (&first, &second);
|
||||
complain_indent (&second, complaint, &i,
|
||||
_("%s redeclaration for %s"), what, s->tag);
|
||||
i += SUB_INDENT;
|
||||
@@ -244,6 +258,7 @@ semantic_type_redeclaration (semantic_type *s, const char *what, location first,
|
||||
location second)
|
||||
{
|
||||
unsigned i = 0;
|
||||
locations_sort (&first, &second);
|
||||
complain_indent (&second, complaint, &i,
|
||||
_("%s redeclaration for <%s>"), what, s->tag);
|
||||
i += SUB_INDENT;
|
||||
|
||||
Reference in New Issue
Block a user