diagnostics: let redundant definitions be only warnings

After all, this is clearly harmless.

* src/muscle-tab.c (muscle_percent_define_insert): Let equal
definitions of a %define variable be only a warning.
Adjust test cases.
This commit is contained in:
Akim Demaille
2019-01-21 19:37:36 +01:00
parent 7498ede3ab
commit 36cae8e752
2 changed files with 37 additions and 29 deletions

View File

@@ -520,21 +520,27 @@ muscle_percent_define_insert (char const *var, location variable_loc,
/* Command-line options are processed before the grammar file. */
bool warned = false;
if (how == MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
&& muscle_find_const (name))
if (how == MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE)
{
muscle_percent_define_how how_old = atoi (muscle_find_const (how_name));
if (how_old == MUSCLE_PERCENT_DEFINE_F)
goto end;
unsigned i = 0;
complain_indent (&variable_loc, complaint, &i,
_("%%define variable %s redefined"),
quote (variable));
i += SUB_INDENT;
location loc = muscle_percent_define_get_loc (variable);
complain_indent (&loc, complaint, &i, _("previous definition"));
fixits_register (&variable_loc, "");
warned = true;
char const *current_value = muscle_find_const (name);
if (current_value)
{
muscle_percent_define_how how_old
= atoi (muscle_find_const (how_name));
if (how_old == MUSCLE_PERCENT_DEFINE_F)
goto end;
unsigned i = 0;
/* If assigning the same value, make it a warning. */
warnings warn = STREQ (value, current_value) ? Wother : complaint;
complain_indent (&variable_loc, warn, &i,
_("%%define variable %s redefined"),
quote (variable));
i += SUB_INDENT;
location loc = muscle_percent_define_get_loc (variable);
complain_indent (&loc, warn, &i, _("previous definition"));
fixits_register (&variable_loc, "");
warned = true;
}
}
if (!warned && old && upd)