diff options
author | Joel E. Denny <joeldenny@joeldenny.org> | 2011-03-27 22:38:32 -0400 |
---|---|---|
committer | Joel E. Denny <joeldenny@joeldenny.org> | 2011-04-09 13:01:41 -0400 |
commit | 786743d5eb46abd8510d0362f558e5271d080fd7 (patch) | |
tree | 04c810bb8b9a58155d92aeae34d9f7c377b8e792 /src | |
parent | e4a148796a4af75b8728f5c4ec7d01a0cc654a27 (diff) | |
download | bison-786743d5eb46abd8510d0362f558e5271d080fd7.tar.gz |
Add -Wconflicts-sr and -Wconflicts-rr.
Thus, conflict reports are now affected by -Werror and -Wnone
(unless %expect or %expect-rr is specified). Reported by George
Neuner at
<http://lists.gnu.org/archive/html/bug-bison/2010-08/msg00002.html>.
* NEWS (2.5): Document.
* doc/bison.texinfo (Bison Options): Document.
* src/complain.c, src/complain.h (set_warning_issued): Export
function.
* src/conflicts.c (conflicts_print): Suppress conflict report
based on -Wno-conflicts-sr and -Wno-conflicts-rr, and treat
conflicts as errors if -Werror.
* src/getargs.c (warnings_flag): Initialize with
warnings_conflicts_sr and warnings_conflicts_rr as well.
(warnings_args, warnings_types): Add entries for
warnings_conflicts_sr and warnings_conflicts_rr.
(usage): Update.
* src/getargs.h (enum warnings): Add entries for
warnings_conflicts_sr and warnings_conflicts_rr.
* tests/conflicts.at (-W versus %expect and %expect-rr): New test
group.
* tests/local.at (AT_BISON_CHECK_NO_XML): Update now that the
conflict report can produce a "warnings being treated as errors"
message. Also, check that stderr is now fully scrubbed by -Wnone
when the exit status is 0.
(cherry picked from commit 6f8bdce25df5669b0b200c2a3848a1c08a44eb79)
Diffstat (limited to 'src')
-rw-r--r-- | src/complain.c | 2 | ||||
-rw-r--r-- | src/complain.h | 7 | ||||
-rw-r--r-- | src/conflicts.c | 9 | ||||
-rw-r--r-- | src/getargs.c | 9 | ||||
-rw-r--r-- | src/getargs.h | 4 |
5 files changed, 28 insertions, 3 deletions
diff --git a/src/complain.c b/src/complain.c index 5629dd3a..5c07fb3d 100644 --- a/src/complain.c +++ b/src/complain.c @@ -94,7 +94,7 @@ error_message (location *loc, | Report a warning, and proceed. | `--------------------------------*/ -static void +void set_warning_issued (void) { static bool warning_issued = false; diff --git a/src/complain.h b/src/complain.h index 3d867f5e..07d401cb 100644 --- a/src/complain.h +++ b/src/complain.h @@ -25,6 +25,13 @@ extern "C" { # endif +/** Record that a warning is about to be issued, and treat it as an + error if <tt>warnings_flag & warnings_error</tt>. This is exported + only for the sake of Yacc-compatible conflict reports in conflicts.c. + All other warnings should be implemented in complain.c and should use + the normal warning format. */ +void set_warning_issued (void); + /** Informative messages, but we proceed. Report iff <tt>warnings_flag & warnings_other</tt>. */ diff --git a/src/conflicts.c b/src/conflicts.c index 96034989..c676e33c 100644 --- a/src/conflicts.c +++ b/src/conflicts.c @@ -599,8 +599,17 @@ conflicts_print (void) return; /* Report the total number of conflicts on STDERR. */ + if (expected_sr_conflicts == -1 && expected_rr_conflicts == -1) + { + if (!(warnings_flag & warnings_conflicts_sr)) + src_total = 0; + if (!(warnings_flag & warnings_conflicts_rr)) + rrc_total = 0; + } if (src_total | rrc_total) { + if (expected_sr_conflicts == -1 && expected_rr_conflicts == -1) + set_warning_issued (); if (! yacc_flag) fprintf (stderr, "%s: ", current_file); conflict_report (stderr, src_total, rrc_total); diff --git a/src/getargs.c b/src/getargs.c index b0e34503..50881aa2 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -59,7 +59,8 @@ bool glr_parser = false; int report_flag = report_none; int trace_flag = trace_none; -int warnings_flag = warnings_other; +int warnings_flag = warnings_conflicts_sr | warnings_conflicts_rr + | warnings_other; static struct bison_language const valid_languages[] = { { "c", "c-skel.m4", ".c", ".h", true }, @@ -230,6 +231,8 @@ static const char * const warnings_args[] = "none - no warnings", "midrule-values - unset or unused midrule values", "yacc - incompatibilities with POSIX Yacc", + "conflicts-sr - S/R conflicts", + "conflicts-rr - R/R conflicts", "other - all other warnings", "all - all of the above", "error - warnings are errors", @@ -241,6 +244,8 @@ static const int warnings_types[] = warnings_none, warnings_midrule_values, warnings_yacc, + warnings_conflicts_sr, + warnings_conflicts_rr, warnings_other, warnings_all, warnings_error @@ -332,6 +337,8 @@ Output:\n\ Warning categories include:\n\ `midrule-values' unset or unused midrule values\n\ `yacc' incompatibilities with POSIX Yacc\n\ + `conflicts-sr' S/R conflicts (enabled by default)\n\ + `conflicts-rr' R/R conflicts (enabled by default)\n\ `other' all other warnings (enabled by default)\n\ `all' all the warnings\n\ `no-CATEGORY' turn off warnings in CATEGORY\n\ diff --git a/src/getargs.h b/src/getargs.h index 1a9d913d..9c505b07 100644 --- a/src/getargs.h +++ b/src/getargs.h @@ -119,7 +119,9 @@ enum warnings warnings_error = 1 << 0, /**< Warnings are treated as errors. */ warnings_midrule_values = 1 << 1, /**< Unset or unused midrule values. */ warnings_yacc = 1 << 2, /**< POSIXME. */ - warnings_other = 1 << 3, /**< All other warnings. */ + warnings_conflicts_sr = 1 << 3, /**< S/R conflicts. */ + warnings_conflicts_rr = 1 << 4, /**< R/R conflicts. */ + warnings_other = 1 << 5, /**< All other warnings. */ warnings_all = ~warnings_error /**< All above warnings. */ }; /** What warnings are issued. */ |