mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
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:
29
ChangeLog
29
ChangeLog
@@ -1,3 +1,32 @@
|
|||||||
|
2011-03-27 Joel E. Denny <joeldenny@joeldenny.org>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
2011-03-27 Joel E. Denny <joeldenny@joeldenny.org>
|
2011-03-27 Joel E. Denny <joeldenny@joeldenny.org>
|
||||||
|
|
||||||
Don't let -Wnone disable -Werror.
|
Don't let -Wnone disable -Werror.
|
||||||
|
|||||||
9
NEWS
9
NEWS
@@ -316,6 +316,15 @@ Bison News
|
|||||||
|
|
||||||
bison -Werror,none,yacc gram.y
|
bison -Werror,none,yacc gram.y
|
||||||
|
|
||||||
|
*** The "none" category now disables all Bison warnings.
|
||||||
|
|
||||||
|
Previously, the "none" category disabled only Bison warnings for
|
||||||
|
which there existed a specific -W/--warning category. However,
|
||||||
|
given the following command line, Bison is now guaranteed to
|
||||||
|
suppress all warnings:
|
||||||
|
|
||||||
|
bison -Wnone gram.y
|
||||||
|
|
||||||
* Changes in version 2.4.3 (2010-08-05):
|
* Changes in version 2.4.3 (2010-08-05):
|
||||||
|
|
||||||
** Bison now obeys -Werror and --warnings=error for warnings about
|
** Bison now obeys -Werror and --warnings=error for warnings about
|
||||||
|
|||||||
1
THANKS
1
THANKS
@@ -41,6 +41,7 @@ Florian Krohm florian@edamail.fishkill.ibm.com
|
|||||||
Frank Heckenbach frank@g-n-u.de
|
Frank Heckenbach frank@g-n-u.de
|
||||||
Frans Englich frans.englich@telia.com
|
Frans Englich frans.englich@telia.com
|
||||||
Georg Sauthoff gsauthof@TechFak.Uni-Bielefeld.DE
|
Georg Sauthoff gsauthof@TechFak.Uni-Bielefeld.DE
|
||||||
|
George Neuner gneuner2@comcast.net
|
||||||
Goran Uddeborg goeran@uddeborg.se
|
Goran Uddeborg goeran@uddeborg.se
|
||||||
Guido Trentalancia trentalg@aston.ac.uk
|
Guido Trentalancia trentalg@aston.ac.uk
|
||||||
H. Merijn Brand h.m.brand@hccnet.nl
|
H. Merijn Brand h.m.brand@hccnet.nl
|
||||||
|
|||||||
@@ -8426,10 +8426,16 @@ These warnings are not enabled by default since they sometimes prove to
|
|||||||
be false alarms in existing grammars employing the Yacc constructs
|
be false alarms in existing grammars employing the Yacc constructs
|
||||||
@code{$0} or @code{$-@var{n}} (where @var{n} is some positive integer).
|
@code{$0} or @code{$-@var{n}} (where @var{n} is some positive integer).
|
||||||
|
|
||||||
|
|
||||||
@item yacc
|
@item yacc
|
||||||
Incompatibilities with POSIX Yacc.
|
Incompatibilities with POSIX Yacc.
|
||||||
|
|
||||||
|
@item other
|
||||||
|
All warnings not categorized above. These warnings are enabled by default.
|
||||||
|
|
||||||
|
This category is provided merely for the sake of completeness. Future
|
||||||
|
releases of Bison may move warnings from this category to new, more specific
|
||||||
|
categories.
|
||||||
|
|
||||||
@item all
|
@item all
|
||||||
All the warnings.
|
All the warnings.
|
||||||
@item none
|
@item none
|
||||||
|
|||||||
@@ -109,6 +109,8 @@ set_warning_issued (void)
|
|||||||
void
|
void
|
||||||
warn_at (location loc, const char *message, ...)
|
warn_at (location loc, const char *message, ...)
|
||||||
{
|
{
|
||||||
|
if (!(warnings_flag & warnings_other))
|
||||||
|
return;
|
||||||
set_warning_issued ();
|
set_warning_issued ();
|
||||||
ERROR_MESSAGE (&loc, _("warning"), message);
|
ERROR_MESSAGE (&loc, _("warning"), message);
|
||||||
}
|
}
|
||||||
@@ -117,6 +119,8 @@ void
|
|||||||
warn_at_indent (location loc, unsigned *indent,
|
warn_at_indent (location loc, unsigned *indent,
|
||||||
const char *message, ...)
|
const char *message, ...)
|
||||||
{
|
{
|
||||||
|
if (!(warnings_flag & warnings_other))
|
||||||
|
return;
|
||||||
set_warning_issued ();
|
set_warning_issued ();
|
||||||
indent_ptr = indent;
|
indent_ptr = indent;
|
||||||
ERROR_MESSAGE (&loc, _("warning"), message);
|
ERROR_MESSAGE (&loc, _("warning"), message);
|
||||||
@@ -125,6 +129,8 @@ warn_at_indent (location loc, unsigned *indent,
|
|||||||
void
|
void
|
||||||
warn (const char *message, ...)
|
warn (const char *message, ...)
|
||||||
{
|
{
|
||||||
|
if (!(warnings_flag & warnings_other))
|
||||||
|
return;
|
||||||
set_warning_issued ();
|
set_warning_issued ();
|
||||||
ERROR_MESSAGE (NULL, _("warning"), message);
|
ERROR_MESSAGE (NULL, _("warning"), message);
|
||||||
}
|
}
|
||||||
@@ -178,6 +184,14 @@ yacc_at (location loc, const char *message, ...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
midrule_value_at (location loc, const char *message, ...)
|
||||||
|
{
|
||||||
|
if (!(warnings_flag & warnings_midrule_values))
|
||||||
|
return;
|
||||||
|
set_warning_issued ();
|
||||||
|
ERROR_MESSAGE (&loc, _("warning"), message);
|
||||||
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------.
|
/*-------------------------------------------------.
|
||||||
| A severe error has occurred, we cannot proceed. |
|
| A severe error has occurred, we cannot proceed. |
|
||||||
|
|||||||
@@ -25,7 +25,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/** Informative messages, but we proceed. */
|
/** Informative messages, but we proceed. Report iff
|
||||||
|
<tt>warnings_flag & warnings_other</tt>. */
|
||||||
|
|
||||||
void warn (char const *format, ...)
|
void warn (char const *format, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 1, 2)));
|
__attribute__ ((__format__ (__printf__, 1, 2)));
|
||||||
@@ -61,6 +62,11 @@ void complain_at_indent (location loc, unsigned *indent,
|
|||||||
void yacc_at (location loc, char const *format, ...)
|
void yacc_at (location loc, char const *format, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
|
||||||
|
/** A midrule-value warning. Report iff
|
||||||
|
<tt>warnings_flag & warnings_midrule_values</tt>. */
|
||||||
|
|
||||||
|
void midrule_value_at (location loc, char const *format, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
|
||||||
/** A fatal error, causing immediate exit. */
|
/** A fatal error, causing immediate exit. */
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ bool glr_parser = false;
|
|||||||
|
|
||||||
int report_flag = report_none;
|
int report_flag = report_none;
|
||||||
int trace_flag = trace_none;
|
int trace_flag = trace_none;
|
||||||
int warnings_flag = warnings_none;
|
int warnings_flag = warnings_other;
|
||||||
|
|
||||||
static struct bison_language const valid_languages[] = {
|
static struct bison_language const valid_languages[] = {
|
||||||
{ "c", "c-skel.m4", ".c", ".h", true },
|
{ "c", "c-skel.m4", ".c", ".h", true },
|
||||||
@@ -234,6 +234,7 @@ static const char * const warnings_args[] =
|
|||||||
"none - no warnings",
|
"none - no warnings",
|
||||||
"midrule-values - unset or unused midrule values",
|
"midrule-values - unset or unused midrule values",
|
||||||
"yacc - incompatibilities with POSIX Yacc",
|
"yacc - incompatibilities with POSIX Yacc",
|
||||||
|
"other - all other warnings",
|
||||||
"all - all of the above",
|
"all - all of the above",
|
||||||
"error - warnings are errors",
|
"error - warnings are errors",
|
||||||
0
|
0
|
||||||
@@ -244,6 +245,7 @@ static const int warnings_types[] =
|
|||||||
warnings_none,
|
warnings_none,
|
||||||
warnings_midrule_values,
|
warnings_midrule_values,
|
||||||
warnings_yacc,
|
warnings_yacc,
|
||||||
|
warnings_other,
|
||||||
warnings_all,
|
warnings_all,
|
||||||
warnings_error
|
warnings_error
|
||||||
};
|
};
|
||||||
@@ -333,6 +335,7 @@ Output:\n\
|
|||||||
Warning categories include:\n\
|
Warning categories include:\n\
|
||||||
`midrule-values' unset or unused midrule values\n\
|
`midrule-values' unset or unused midrule values\n\
|
||||||
`yacc' incompatibilities with POSIX Yacc\n\
|
`yacc' incompatibilities with POSIX Yacc\n\
|
||||||
|
`other' all other warnings (enabled by default)\n\
|
||||||
`all' all the warnings\n\
|
`all' all the warnings\n\
|
||||||
`no-CATEGORY' turn off warnings in CATEGORY\n\
|
`no-CATEGORY' turn off warnings in CATEGORY\n\
|
||||||
`none' turn off all the warnings\n\
|
`none' turn off all the warnings\n\
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ enum warnings
|
|||||||
warnings_error = 1 << 0, /**< Warnings are treated as errors. */
|
warnings_error = 1 << 0, /**< Warnings are treated as errors. */
|
||||||
warnings_midrule_values = 1 << 1, /**< Unset or unused midrule values. */
|
warnings_midrule_values = 1 << 1, /**< Unset or unused midrule values. */
|
||||||
warnings_yacc = 1 << 2, /**< POSIXME. */
|
warnings_yacc = 1 << 2, /**< POSIXME. */
|
||||||
|
warnings_other = 1 << 3, /**< All other warnings. */
|
||||||
warnings_all = ~warnings_error /**< All above warnings. */
|
warnings_all = ~warnings_error /**< All above warnings. */
|
||||||
};
|
};
|
||||||
/** What warnings are issued. */
|
/** What warnings are issued. */
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <quotearg.h>
|
#include <quotearg.h>
|
||||||
|
|
||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
|
#include "getargs.h"
|
||||||
#include "gram.h"
|
#include "gram.h"
|
||||||
#include "print-xml.h"
|
#include "print-xml.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
@@ -310,8 +311,11 @@ grammar_rules_useless_report (const char *message)
|
|||||||
if (!rules[r].useful)
|
if (!rules[r].useful)
|
||||||
{
|
{
|
||||||
warn_at (rules[r].location, "%s: ", message);
|
warn_at (rules[r].location, "%s: ", message);
|
||||||
rule_print (&rules[r], stderr);
|
if (warnings_flag & warnings_other)
|
||||||
fflush (stderr);
|
{
|
||||||
|
rule_print (&rules[r], stderr);
|
||||||
|
fflush (stderr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
48
src/reader.c
48
src/reader.c
@@ -250,22 +250,25 @@ grammar_current_rule_begin (symbol *lhs, location loc,
|
|||||||
/*----------------------------------------------------------------------.
|
/*----------------------------------------------------------------------.
|
||||||
| A symbol should be used if either: |
|
| A symbol should be used if either: |
|
||||||
| 1. It has a destructor. |
|
| 1. It has a destructor. |
|
||||||
| 2. --warnings=midrule-values and the symbol is a mid-rule symbol |
|
| 2. The symbol is a mid-rule symbol (i.e., the generated LHS |
|
||||||
| (i.e., the generated LHS replacing a mid-rule action) that was |
|
| replacing a mid-rule action) that was assigned to or used, as in |
|
||||||
| assigned to or used, as in "exp: { $$ = 1; } { $$ = $1; }". |
|
| "exp: { $$ = 1; } { $$ = $1; }". |
|
||||||
`----------------------------------------------------------------------*/
|
`----------------------------------------------------------------------*/
|
||||||
|
|
||||||
static bool
|
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)
|
if (symbol_destructor_get (s->content.sym)->code)
|
||||||
return true;
|
return true;
|
||||||
if (warnings_flag & warnings_midrule_values)
|
if ((s->midrule && s->midrule->action_props.is_value_used)
|
||||||
return ((s->midrule && s->midrule->action_props.is_value_used)
|
|| (s->midrule_parent_rule
|
||||||
|| (s->midrule_parent_rule
|
&& symbol_list_n_get (s->midrule_parent_rule,
|
||||||
&& symbol_list_n_get (s->midrule_parent_rule,
|
s->midrule_parent_rhs_index)
|
||||||
s->midrule_parent_rhs_index)
|
->action_props.is_value_used))
|
||||||
->action_props.is_value_used));
|
{
|
||||||
|
*midrule_warning = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,16 +312,21 @@ grammar_rule_check (const symbol_list *r)
|
|||||||
symbol_list const *l = r;
|
symbol_list const *l = r;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (; l && l->content.sym; l = l->next, ++n)
|
for (; l && l->content.sym; l = l->next, ++n)
|
||||||
if (! (l->action_props.is_value_used
|
{
|
||||||
|| !symbol_should_be_used (l)
|
bool midrule_warning = false;
|
||||||
/* The default action, $$ = $1, `uses' both. */
|
if (!l->action_props.is_value_used
|
||||||
|| (!r->action_props.code && (n == 0 || n == 1))))
|
&& symbol_should_be_used (l, &midrule_warning)
|
||||||
{
|
/* The default action, $$ = $1, `uses' both. */
|
||||||
if (n)
|
&& (r->action_props.code || (n != 0 && n != 1)))
|
||||||
warn_at (r->location, _("unused value: $%d"), n);
|
{
|
||||||
else
|
void (*warn_at_ptr)(location, char const*, ...) =
|
||||||
warn_at (r->location, _("unset value: $$"));
|
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
|
/* See comments in grammar_current_rule_prec_set for how POSIX
|
||||||
|
|||||||
@@ -242,8 +242,10 @@ $2])
|
|||||||
|
|
||||||
# AT_BISON_CHECK(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
# AT_BISON_CHECK(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# Check Bison by invoking `bison BISON_ARGS'. OTHER_AT_CHECK_ARGS are the
|
# Check Bison by invoking `bison BISON_ARGS'. BISON_ARGS should not contain
|
||||||
# usual remaining arguments to AT_CHECK: STATUS, STDOUT, etc.
|
# shell constructs (such as redirection or pipes) that would prevent
|
||||||
|
# appending additional command-line arguments for bison. OTHER_AT_CHECK_ARGS
|
||||||
|
# are the usual remaining arguments to AT_CHECK: STATUS, STDOUT, etc.
|
||||||
#
|
#
|
||||||
# This macro or AT_BISON_CHECK_NO_XML should always be used whenever invoking
|
# This macro or AT_BISON_CHECK_NO_XML should always be used whenever invoking
|
||||||
# Bison in the test suite. For now it ensures that:
|
# Bison in the test suite. For now it ensures that:
|
||||||
@@ -257,6 +259,8 @@ $2])
|
|||||||
#
|
#
|
||||||
# 3. If stderr contains a warning, -Werror and --warnings=error
|
# 3. If stderr contains a warning, -Werror and --warnings=error
|
||||||
# convert the warning to an error.
|
# convert the warning to an error.
|
||||||
|
#
|
||||||
|
# 4. If stderr contains a warning, -Wnone and --warnings=none suppress it.
|
||||||
m4_define([AT_BISON_CHECK],
|
m4_define([AT_BISON_CHECK],
|
||||||
[m4_if(m4_quote($2), [0], [AT_BISON_CHECK_XML($@)],
|
[m4_if(m4_quote($2), [0], [AT_BISON_CHECK_XML($@)],
|
||||||
m4_quote($2), [], [AT_BISON_CHECK_XML($@)])
|
m4_quote($2), [], [AT_BISON_CHECK_XML($@)])
|
||||||
@@ -282,10 +286,16 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
|
|||||||
if test -f experr; then
|
if test -f experr; then
|
||||||
mv experr at-bison-check-experr.bak
|
mv experr at-bison-check-experr.bak
|
||||||
fi
|
fi
|
||||||
|
if test -f expout; then
|
||||||
|
mv expout at-bison-check-expout.bak
|
||||||
|
fi
|
||||||
|
|
||||||
|
# To avoid expanding it repeatedly, store specified stdout.
|
||||||
|
]AT_DATA([expout], [$3])[
|
||||||
|
|
||||||
# Run with -Werror.
|
# Run with -Werror.
|
||||||
]AT_CHECK(AT_QUELL_VALGRIND[[ bison -Werror ]$1],
|
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Werror]],
|
||||||
[[1]], [$3], [stderr])[
|
[[1]], [expout], [stderr])[
|
||||||
|
|
||||||
# Build expected stderr up to and including the "warnings
|
# Build expected stderr up to and including the "warnings
|
||||||
# being treated as errors" message.
|
# being treated as errors" message.
|
||||||
@@ -317,10 +327,21 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
|
|||||||
|
|
||||||
# Now check --warnings=error.
|
# Now check --warnings=error.
|
||||||
cp stderr experr
|
cp stderr experr
|
||||||
]AT_CHECK(AT_QUELL_VALGRIND[[ bison --warnings=error ]$1],
|
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=error]],
|
||||||
[[1]], [$3], [experr])[
|
[[1]], [expout], [experr])[
|
||||||
|
|
||||||
|
# Now check -Wnone and --warnings=none by making sure that
|
||||||
|
# -Werror doesn't change the exit status when -Wnone or
|
||||||
|
# --warnings=none is specified.
|
||||||
|
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Wnone -Werror]],
|
||||||
|
[[0]], [expout], [ignore])[
|
||||||
|
]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=none \
|
||||||
|
-Werror]], [[0]], [expout], [ignore])[
|
||||||
|
|
||||||
# Restore caller's files.
|
# Restore caller's files.
|
||||||
|
if test -f at-bison-check-expout.bak; then
|
||||||
|
mv at-bison-check-expout.bak expout
|
||||||
|
fi
|
||||||
if test -f at-bison-check-experr.bak; then
|
if test -f at-bison-check-experr.bak; then
|
||||||
mv at-bison-check-experr.bak experr
|
mv at-bison-check-experr.bak experr
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user