mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 04:43:03 +00:00
c++: issue a warning with a value is moved several times
Suggested by Frank Heckenbach. http://lists.gnu.org/archive/html/bug-bison/2018-09/msg00022.html * src/scan-code.l (parse_ref): Check multiple occurrences of rhs values. * tests/c++.at (Multiple occurrences of $n and api.value.automove): New.
This commit is contained in:
@@ -439,26 +439,22 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
if ('[' == *cp)
|
||||
{
|
||||
/* Ignore the brackets. */
|
||||
char *p;
|
||||
for (p = ++cp; *p != ']'; ++p)
|
||||
for (cp_end = ++cp; *cp_end != ']'; ++cp_end)
|
||||
continue;
|
||||
cp_end = p;
|
||||
|
||||
explicit_bracketing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Take all characters of the name. */
|
||||
char* p;
|
||||
for (p = cp; *p; ++p)
|
||||
for (char* p = cp; *p; ++p)
|
||||
if (is_dot_or_dash (*p))
|
||||
{
|
||||
ref_tail_fields = p;
|
||||
break;
|
||||
}
|
||||
for (p = cp; *p; ++p)
|
||||
for (cp_end = cp; *cp_end; ++cp_end)
|
||||
continue;
|
||||
cp_end = p;
|
||||
|
||||
explicit_bracketing = false;
|
||||
}
|
||||
@@ -705,8 +701,15 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
||||
obstack_quote (&obstack_for_string, type_name);
|
||||
obstack_sgrow (&obstack_for_string, ")[");
|
||||
if (0 < n)
|
||||
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
|
||||
true;
|
||||
{
|
||||
symbol_list *sym = symbol_list_n_get (effective_rule, n);
|
||||
if (muscle_percent_define_ifdef ("api.value.automove")
|
||||
&& sym->action_props.is_value_used)
|
||||
complain (&dollar_loc, Wother,
|
||||
_("multiple occurrences of $%s with api.value.automove enabled"),
|
||||
cp);
|
||||
sym->action_props.is_value_used = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user