parser: improve location of string alias errors

* src/parse-gram.y (symbol_def): Pass the right location for symbol_make_alias.
* tests/regression.at (Duplicate string): Move to...
* tests/input.at: here.
(Token collisions): New.
This commit is contained in:
Akim Demaille
2018-11-27 21:07:21 +01:00
parent d92ed9d9f7
commit 2c5e933672
4 changed files with 63 additions and 37 deletions

View File

@@ -530,7 +530,7 @@ symbol_def:
}
symbol_class_set ($1, current_class, @1, true);
symbol_type_set ($1, current_type, @1);
symbol_make_alias ($1, $2, @$);
symbol_make_alias ($1, $2, @2);
}
| id INT string_as_id
{
@@ -545,7 +545,7 @@ symbol_def:
symbol_class_set ($1, current_class, @1, true);
symbol_type_set ($1, current_type, @1);
symbol_user_token_number_set ($1, $2, @2);
symbol_make_alias ($1, $3, @$);
symbol_make_alias ($1, $3, @3);
}
;

View File

@@ -462,9 +462,7 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
void
symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
{
int *user_token_numberp;
user_token_numberp = &sym->content->user_token_number;
int *user_token_numberp = &sym->content->user_token_number;
if (*user_token_numberp != USER_NUMBER_UNDEFINED
&& *user_token_numberp != user_token_number)
complain (&loc, complaint, _("redefining user token number of %s"),