mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 17:23:02 +00:00
diagnostics: better location for type redeclarations
From
foo.y:1.7-11: error: %type redeclaration for bar
1 | %type <foo> bar bar
| ^~~~~
foo.y:1.7-11: note: previous declaration
1 | %type <foo> bar bar
| ^~~~~
to
foo.y:1.17-19: error: %type redeclaration for bar
1 | %type <foo> bar bar
| ^~~
foo.y:1.13-15: note: previous declaration
1 | %type <foo> bar bar
| ^~~
* src/symlist.h, src/symlist.c (symbol_list_type_set): There's no need
for the tag's location, use that of the symbol.
* src/parse-gram.y: Adjust.
* tests/input.at: Adjust.
This commit is contained in:
8
NEWS
8
NEWS
@@ -2,8 +2,16 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
* Noteworthy changes in release ?.? (????-??-??) [?]
|
* Noteworthy changes in release ?.? (????-??-??) [?]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Fixed a crash when a token alias contains a NUL byte.
|
||||||
|
|
||||||
|
** Changes
|
||||||
|
|
||||||
Improvements and fixes in the documentation.
|
Improvements and fixes in the documentation.
|
||||||
|
|
||||||
|
More precise location about symbol type redefinitions.
|
||||||
|
|
||||||
|
|
||||||
* Noteworthy changes in release 3.7 (2020-07-23) [stable]
|
* Noteworthy changes in release 3.7 (2020-07-23) [stable]
|
||||||
|
|
||||||
|
|||||||
@@ -532,11 +532,11 @@ token_decls:
|
|||||||
}
|
}
|
||||||
| TAG token_decl.1[syms]
|
| TAG token_decl.1[syms]
|
||||||
{
|
{
|
||||||
$$ = symbol_list_type_set ($syms, $TAG, @TAG);
|
$$ = symbol_list_type_set ($syms, $TAG);
|
||||||
}
|
}
|
||||||
| token_decls TAG token_decl.1[syms]
|
| token_decls TAG token_decl.1[syms]
|
||||||
{
|
{
|
||||||
$$ = symbol_list_append ($1, symbol_list_type_set ($syms, $TAG, @TAG));
|
$$ = symbol_list_append ($1, symbol_list_type_set ($syms, $TAG));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -592,11 +592,11 @@ token_decls_for_prec:
|
|||||||
}
|
}
|
||||||
| TAG token_decl_for_prec.1[syms]
|
| TAG token_decl_for_prec.1[syms]
|
||||||
{
|
{
|
||||||
$$ = symbol_list_type_set ($syms, $TAG, @TAG);
|
$$ = symbol_list_type_set ($syms, $TAG);
|
||||||
}
|
}
|
||||||
| token_decls_for_prec TAG token_decl_for_prec.1[syms]
|
| token_decls_for_prec TAG token_decl_for_prec.1[syms]
|
||||||
{
|
{
|
||||||
$$ = symbol_list_append ($1, symbol_list_type_set ($syms, $TAG, @TAG));
|
$$ = symbol_list_append ($1, symbol_list_type_set ($syms, $TAG));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -632,11 +632,11 @@ symbol_decls:
|
|||||||
}
|
}
|
||||||
| TAG symbol_decl.1[syms]
|
| TAG symbol_decl.1[syms]
|
||||||
{
|
{
|
||||||
$$ = symbol_list_type_set ($syms, $TAG, @TAG);
|
$$ = symbol_list_type_set ($syms, $TAG);
|
||||||
}
|
}
|
||||||
| symbol_decls TAG symbol_decl.1[syms]
|
| symbol_decls TAG symbol_decl.1[syms]
|
||||||
{
|
{
|
||||||
$$ = symbol_list_append ($1, symbol_list_type_set ($syms, $TAG, @TAG));
|
$$ = symbol_list_append ($1, symbol_list_type_set ($syms, $TAG));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ symbol_list_type_new (uniqstr type_name, location loc)
|
|||||||
|
|
||||||
|
|
||||||
symbol_list *
|
symbol_list *
|
||||||
symbol_list_type_set (symbol_list *syms, uniqstr type_name, location loc)
|
symbol_list_type_set (symbol_list *syms, uniqstr type_name)
|
||||||
{
|
{
|
||||||
for (symbol_list *l = syms; l; l = l->next)
|
for (symbol_list *l = syms; l; l = l->next)
|
||||||
symbol_type_set (l->content.sym, type_name, loc);
|
symbol_type_set (l->content.sym, type_name, l->sym_loc);
|
||||||
return syms;
|
return syms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,8 +110,7 @@ symbol_list *symbol_list_type_new (uniqstr type_name, location loc);
|
|||||||
|
|
||||||
/** Assign the type \c type_name to all the members of \c syms.
|
/** Assign the type \c type_name to all the members of \c syms.
|
||||||
** \returns \c syms */
|
** \returns \c syms */
|
||||||
symbol_list *symbol_list_type_set (symbol_list *syms,
|
symbol_list *symbol_list_type_set (symbol_list *syms, uniqstr type_name);
|
||||||
uniqstr type_name, location loc);
|
|
||||||
|
|
||||||
/** Print this list.
|
/** Print this list.
|
||||||
|
|
||||||
|
|||||||
@@ -1252,12 +1252,12 @@ AT_TEST([[%token foo "foo"
|
|||||||
%%
|
%%
|
||||||
exp: foo;
|
exp: foo;
|
||||||
]],
|
]],
|
||||||
[[input.y:3.7-11: error: %type redeclaration for foo
|
[[input.y:3.13-15: error: %type redeclaration for foo
|
||||||
3 | %type <baz> foo
|
3 | %type <baz> foo
|
||||||
| ^~~~~
|
| ^~~
|
||||||
input.y:2.7-11: note: previous declaration
|
input.y:2.13-17: note: previous declaration
|
||||||
2 | %type <bar> "foo"
|
2 | %type <bar> "foo"
|
||||||
| ^~~~~
|
| ^~~~~
|
||||||
]])
|
]])
|
||||||
|
|
||||||
AT_TEST([[%token foo "foo"
|
AT_TEST([[%token foo "foo"
|
||||||
|
|||||||
Reference in New Issue
Block a user