Add -Wother so -Wnone suppresses all warnings.

Reported by George Neuner at
<http://lists.gnu.org/archive/html/bug-bison/2010-08/msg00002.html>.
* NEWS (2.5): Document.
* THANKS (George Neuner): Add.
* doc/bison.texinfo (Bison Options): Document.
* src/complain.c, src/complain.h
(warn_at, warn_at_indent, warn): Suppress warning if -Wno-other.
(midrule_value_at): New warning function, similar to yacc_at in
that it's controlled by its own warning category.
* src/getargs.c (warnings_flag): Initialize to warnings_other.
(warnings_args, warnings_types): Add entry for warnings_other.
(usage): Update.
* src/getargs.h (enum warnings): Add entry for warnings_other.
* src/gram.c (grammar_rules_useless_report): If -Wno-other, then
don't print useless rules.
* src/reader.c (symbol_should_be_used): Rather than adjusting the
return value based on whether midrule value warnings are enabled,
accept a new parameter for telling the caller whether true is
being returned for a potential midrule warning.
(grammar_rule_check): Use midrule_value_at for midrule value
warnings, and continue to use warn_at for all other warnings.  Let
them check whether the warnings are enabled.
* tests/local.at (AT_BISON_CHECK): Update documentation.
(AT_BISON_CHECK_NO_XML): Check that -Wnone and --warnings=none
disable all warnings exercised in the test suite.
This commit is contained in:
Joel E. Denny
2011-03-27 19:08:24 -04:00
parent dab9663283
commit 8ffd7912e3
11 changed files with 133 additions and 31 deletions

View File

@@ -250,22 +250,25 @@ grammar_current_rule_begin (symbol *lhs, location loc,
/*----------------------------------------------------------------------.
| A symbol should be used if either: |
| 1. It has a destructor. |
| 2. --warnings=midrule-values and the symbol is a mid-rule symbol |
| (i.e., the generated LHS replacing a mid-rule action) that was |
| assigned to or used, as in "exp: { $$ = 1; } { $$ = $1; }". |
| 2. The symbol is a mid-rule symbol (i.e., the generated LHS |
| replacing a mid-rule action) that was assigned to or used, as in |
| "exp: { $$ = 1; } { $$ = $1; }". |
`----------------------------------------------------------------------*/
static bool
symbol_should_be_used (symbol_list const *s)
symbol_should_be_used (symbol_list const *s, bool *midrule_warning)
{
if (symbol_destructor_get (s->content.sym)->code)
return true;
if (warnings_flag & warnings_midrule_values)
return ((s->midrule && s->midrule->action_props.is_value_used)
|| (s->midrule_parent_rule
&& symbol_list_n_get (s->midrule_parent_rule,
s->midrule_parent_rhs_index)
->action_props.is_value_used));
if ((s->midrule && s->midrule->action_props.is_value_used)
|| (s->midrule_parent_rule
&& symbol_list_n_get (s->midrule_parent_rule,
s->midrule_parent_rhs_index)
->action_props.is_value_used))
{
*midrule_warning = true;
return true;
}
return false;
}
@@ -309,16 +312,21 @@ grammar_rule_check (const symbol_list *r)
symbol_list const *l = r;
int n = 0;
for (; l && l->content.sym; l = l->next, ++n)
if (! (l->action_props.is_value_used
|| !symbol_should_be_used (l)
/* The default action, $$ = $1, `uses' both. */
|| (!r->action_props.code && (n == 0 || n == 1))))
{
if (n)
warn_at (r->location, _("unused value: $%d"), n);
else
warn_at (r->location, _("unset value: $$"));
}
{
bool midrule_warning = false;
if (!l->action_props.is_value_used
&& symbol_should_be_used (l, &midrule_warning)
/* The default action, $$ = $1, `uses' both. */
&& (r->action_props.code || (n != 0 && n != 1)))
{
void (*warn_at_ptr)(location, char const*, ...) =
midrule_warning ? midrule_value_at : warn_at;
if (n)
warn_at_ptr (r->location, _("unused value: $%d"), n);
else
warn_at_ptr (r->location, _("unset value: $$"));
}
}
}
/* See comments in grammar_current_rule_prec_set for how POSIX