diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2019-01-21 19:37:36 +0100 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-01-22 06:54:28 +0100 |
commit | 36cae8e75220856a6b31f9df0c9d86354473f8a1 (patch) | |
tree | 02514e94b70fde8f2ceef98b4ae4adf28edf8a6f /src/muscle-tab.c | |
parent | 7498ede3abaa38ab383b4dacbac0fd0c946b4e5e (diff) | |
download | bison-36cae8e75220856a6b31f9df0c9d86354473f8a1.tar.gz |
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.
Diffstat (limited to 'src/muscle-tab.c')
-rw-r--r-- | src/muscle-tab.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/muscle-tab.c b/src/muscle-tab.c index 618e4d5f..8a1b00fc 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -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) |