bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: warning flags in 2.4.1


From: Joel E. Denny
Subject: Re: warning flags in 2.4.1
Date: Sun, 27 Mar 2011 22:56:17 -0400 (EDT)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

On Wed, 4 Aug 2010, Joel E. Denny wrote:

> On Mon, 2 Aug 2010, Joel E. Denny wrote:
> 
> > > Also on page 114, the manual says "--warnings=none" or "-Wnone" should
> > > suppress all warnings.  This does not work.  Grammar warnings, if any, are
> > > generated regardless of this setting.
> > 
> > Thanks for mentioning that.  I hadn't noticed it before, and I agree it is 
> > confusing.  I think the idea was that -Wnone (or --warnings=none) simply 
> > disables all warnings that can be enabled by the other -W options.  It's 
> > not clear to me if the documentation or the behavior needs to be fixed 
> > here.
> 
> Any opinions on this from anyone?
> 
> If we decide that -Wnone should affect all warnings, then we probably need 
> to add some kind of -Wother option for all warnings that do not have their 
> own -W option.  The documentation should make it clear that we might later 
> move warnings from -Wother to new, more specific -W options.

I feel that -Wnone should affect all warnings.  That's how it's currently 
documented, and it seems like a useful feature.  I'd like to push the 
following patches to branch-2.5 and master.  Any objections?

>From 47fd7a53f3c5861db396c369614905b623afd87b Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Sun, 27 Mar 2011 19:08:24 -0400
Subject: [PATCH 1/2] 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/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.
---
 ChangeLog         |   27 +++++++++++++++++++++++++++
 NEWS              |    9 +++++++++
 THANKS            |    1 +
 doc/bison.texinfo |    8 +++++++-
 src/complain.c    |   14 ++++++++++++++
 src/complain.h    |    8 +++++++-
 src/getargs.c     |    5 ++++-
 src/getargs.h     |    1 +
 src/reader.c      |   48 ++++++++++++++++++++++++++++--------------------
 tests/local.at    |   34 ++++++++++++++++++++++++++++------
 10 files changed, 126 insertions(+), 29 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4eb5ebd..eb2e1f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,32 @@
 2011-03-27  Joel E. Denny  <address@hidden>
 
+       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/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  <address@hidden>
+
        Don't let -Wnone disable -Werror.
        Discussed at
        <http://lists.gnu.org/archive/html/bison-patches/2010-08/msg00009.html>.
diff --git a/NEWS b/NEWS
index 243ada5..7584f18 100644
--- a/NEWS
+++ b/NEWS
@@ -316,6 +316,15 @@ Bison News
 
     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):
 
 ** Bison now obeys -Werror and --warnings=error for warnings about
diff --git a/THANKS b/THANKS
index ad6f379..8ce5728 100644
--- a/THANKS
+++ b/THANKS
@@ -41,6 +41,7 @@ Florian Krohm             address@hidden
 Frank Heckenbach          address@hidden
 Frans Englich             address@hidden
 Georg Sauthoff            address@hidden
+George Neuner             address@hidden
 Goran Uddeborg            address@hidden
 Guido Trentalancia        address@hidden
 H. Merijn Brand           address@hidden
diff --git a/doc/bison.texinfo b/doc/bison.texinfo
index 8ecb5fb..cb50a01 100644
--- a/doc/bison.texinfo
+++ b/doc/bison.texinfo
@@ -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
 @code{$0} or @address@hidden (where @var{n} is some positive integer).
 
-
 @item yacc
 Incompatibilities with POSIX Yacc.
 
address@hidden 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
 All the warnings.
 @item none
diff --git a/src/complain.c b/src/complain.c
index 3b0041e..5629dd3 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -109,6 +109,8 @@ set_warning_issued (void)
 void
 warn_at (location loc, const char *message, ...)
 {
+  if (!(warnings_flag & warnings_other))
+    return;
   set_warning_issued ();
   ERROR_MESSAGE (&loc, _("warning"), message);
 }
@@ -117,6 +119,8 @@ void
 warn_at_indent (location loc, unsigned *indent,
                 const char *message, ...)
 {
+  if (!(warnings_flag & warnings_other))
+    return;
   set_warning_issued ();
   indent_ptr = indent;
   ERROR_MESSAGE (&loc, _("warning"), message);
@@ -125,6 +129,8 @@ warn_at_indent (location loc, unsigned *indent,
 void
 warn (const char *message, ...)
 {
+  if (!(warnings_flag & warnings_other))
+    return;
   set_warning_issued ();
   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.  |
diff --git a/src/complain.h b/src/complain.h
index f628175..3d867f5 100644
--- a/src/complain.h
+++ b/src/complain.h
@@ -25,7 +25,8 @@
 extern "C" {
 # endif
 
-/** Informative messages, but we proceed.  */
+/** Informative messages, but we proceed.  Report iff
+    <tt>warnings_flag & warnings_other</tt>.  */
 
 void warn (char const *format, ...)
   __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, ...)
   __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.  */
 
diff --git a/src/getargs.c b/src/getargs.c
index c558322..03c7a3d 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -63,7 +63,7 @@ bool glr_parser = false;
 
 int report_flag = report_none;
 int trace_flag = trace_none;
-int warnings_flag = warnings_none;
+int warnings_flag = warnings_other;
 
 static struct bison_language const valid_languages[] = {
   { "c", "c-skel.m4", ".c", ".h", true },
@@ -232,6 +232,7 @@ static const char * const warnings_args[] =
   "none            - no warnings",
   "midrule-values  - unset or unused midrule values",
   "yacc            - incompatibilities with POSIX Yacc",
+  "other           - all other warnings",
   "all             - all of the above",
   "error           - warnings are errors",
   0
@@ -242,6 +243,7 @@ static const int warnings_types[] =
   warnings_none,
   warnings_midrule_values,
   warnings_yacc,
+  warnings_other,
   warnings_all,
   warnings_error
 };
@@ -331,6 +333,7 @@ Output:\n\
 Warning categories include:\n\
   `midrule-values'  unset or unused midrule values\n\
   `yacc'            incompatibilities with POSIX Yacc\n\
+  `other'           all other warnings (enabled by default)\n\
   `all'             all the warnings\n\
   `no-CATEGORY'     turn off warnings in CATEGORY\n\
   `none'            turn off all the warnings\n\
diff --git a/src/getargs.h b/src/getargs.h
index 6f99435..dc92584 100644
--- a/src/getargs.h
+++ b/src/getargs.h
@@ -123,6 +123,7 @@ 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_all              = ~warnings_error /**< All above warnings.  */
   };
 /** What warnings are issued.  */
diff --git a/src/reader.c b/src/reader.c
index eb95070..92db571 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -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
diff --git a/tests/local.at b/tests/local.at
index 9ccc2c5..321ab50 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -242,8 +242,10 @@ $2])
 
 # AT_BISON_CHECK(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
 # -------------------------------------------------
-# Check Bison by invoking `bison BISON_ARGS'.  OTHER_AT_CHECK_ARGS are the
-# usual remaining arguments to AT_CHECK: STATUS, STDOUT, etc.
+# Check Bison by invoking `bison BISON_ARGS'.  BISON_ARGS should not contain
+# 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
 # Bison in the test suite.  For now it ensures that:
@@ -257,6 +259,9 @@ $2])
 #
 #   3. If stderr contains a warning, -Werror and --warnings=error
 #      convert the warning to an error.
+#
+#   4. If stderr contains a warning, -Wnone and --warnings-none suppresses
+#      it.
 m4_define([AT_BISON_CHECK],
 [m4_if(m4_quote($2), [0], [AT_BISON_CHECK_XML($@)],
        m4_quote($2), [], [AT_BISON_CHECK_XML($@)])
@@ -282,10 +287,16 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
               if test -f experr; then
                 mv experr at-bison-check-experr.bak
               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.
-              ]AT_CHECK(AT_QUELL_VALGRIND[[ bison -Werror ]$1],
-                        [[1]], [$3], [stderr])[
+              ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Werror]],
+                        [[1]], [expout], [stderr])[
 
               # Build expected stderr up to and including the "warnings
               # being treated as errors" message.
@@ -317,10 +328,21 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
 
               # Now check --warnings=error.
               cp stderr experr
-              ]AT_CHECK(AT_QUELL_VALGRIND[[ bison --warnings=error ]$1],
-                        [[1]], [$3], [experr])[
+              ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=error]],
+                        [[1]], [expout], [experr])[
+
+              # Now check -Wnone and --warnings=none by making sure
+              # -Werror doesn't change the exit status when -Wnone 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.
+              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
                 mv at-bison-check-experr.bak experr
               fi
-- 
1.7.0.4


>From 5da21a999066c6bba77a4952aa6a0615617814f3 Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Sun, 27 Mar 2011 19:29:37 -0400
Subject: [PATCH 2/2] Pacify maintainer-check-posix.

Adding command-line options after the grammar file name is not
permitted, so disable checks that do that when
maintainer-check-posix is running.
* tests/local.at (AT_BISON_CHECK_NO_XML): Don't run the
problematic checks when POSIXLY_CORRECT=1.  Also, for readability,
remove an unnecessary m4_if.
---
 ChangeLog      |   10 ++++
 tests/local.at |  139 +++++++++++++++++++++++++++-----------------------------
 2 files changed, 77 insertions(+), 72 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eb2e1f9..893beb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2011-03-27  Joel E. Denny  <address@hidden>
 
+       Pacify maintainer-check-posix.
+       Adding command-line options after the grammar file name is not
+       permitted, so disable checks that do that when
+       maintainer-check-posix is running.
+       * tests/local.at (AT_BISON_CHECK_NO_XML): Don't run the
+       problematic checks when POSIXLY_CORRECT=1.  Also, for readability,
+       remove an unnecessary m4_if.
+
+2011-03-27  Joel E. Denny  <address@hidden>
+
        Add -Wother so -Wnone suppresses all warnings.
        Reported by George Neuner at
        <http://lists.gnu.org/archive/html/bug-bison/2010-08/msg00002.html>.
diff --git a/tests/local.at b/tests/local.at
index 321ab50..1aaab9b 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -279,78 +279,73 @@ m4_define([AT_BISON_CHECK_NO_XML],
 [AT_CHECK(m4_if(m4_quote($2), [0], [], m4_quote($2), [], [],
                 [AT_QUELL_VALGRIND ])[[bison ]]$@)
 m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
-      [m4_if(m4_quote(m4_if(m4_quote($2), [], [0], [$2])), [0],
-             [[# Don't interfere with caller's files.
-              if test -f stderr; then
-                mv stderr at-bison-check-stderr.bak
-              fi
-              if test -f experr; then
-                mv experr at-bison-check-experr.bak
-              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.
-              ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Werror]],
-                        [[1]], [expout], [stderr])[
-
-              # Build expected stderr up to and including the "warnings
-              # being treated as errors" message.
-              ]AT_DATA([[at-bison-check-warnings]], [$4])[
-              at_bison_check_first="` \
-                sed -n '/: warning: /=' at-bison-check-warnings \
-                | sed -n 1p \
-              `"
-              if test $at_bison_check_first -gt 1; then
-                sed -n "1,`expr $at_bison_check_first - 1`"p \
-                  at-bison-check-warnings > experr
-              fi
-              echo ']AT_BISON_WERROR_MSG[' >> experr
-
-              # Finish building expected stderr and check.  Unlike
-              # warnings, complaints cause bison to exit early.  Thus,
-              # with -Werror, bison does not necessarily report all
-              # warnings that it does without -Werror, but it at least
-              # reports one.
-              at_bison_check_last="`sed -n '$=' stderr`"
-              if test x"$at_bison_check_last" = x; then
-                at_bison_check_last=1
-              fi
-              at_bison_check_last="`expr $at_bison_check_last - 1`"
-              sed -n "$at_bison_check_first,$at_bison_check_last"p \
-                at-bison-check-warnings >> experr
-              ]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \
-                          stderr 1>&2]], [[0]], [[]], [experr])[
-
-              # Now check --warnings=error.
-              cp stderr experr
-              ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=error]],
-                        [[1]], [expout], [experr])[
-
-              # Now check -Wnone and --warnings=none by making sure
-              # -Werror doesn't change the exit status when -Wnone 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.
-              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
-                mv at-bison-check-experr.bak experr
-              fi
-              if test -f at-bison-check-stderr.bak; then
-                mv at-bison-check-stderr.bak stderr
-              fi
-             ]])
-      ])
+      m4_quote(m4_if(m4_quote($2), [], [0], [$2])), [0], [[
+        # POSIXLY_CORRECT=1 causes bison to complain if options are added
+        # after the grammar file name, so skip these checks in that case.
+        if test x"$POSIXLY_CORRECT" != x1; then
+          # Don't interfere with caller's files.
+          if test -f stderr; then mv stderr at-bison-check-stderr.bak; fi
+          if test -f experr; then mv experr at-bison-check-experr.bak; 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.
+          ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Werror]],
+                    [[1]], [expout], [stderr])[
+
+          # Build expected stderr up to and including the "warnings being
+          # treated as errors" message.
+          ]AT_DATA([[at-bison-check-warnings]], [$4])[
+          at_bison_check_first="` \
+            sed -n '/: warning: /=' at-bison-check-warnings \
+            | sed -n 1p \
+          `"
+          if test $at_bison_check_first -gt 1; then
+            sed -n "1,`expr $at_bison_check_first - 1`"p \
+              at-bison-check-warnings > experr
+          fi
+          echo ']AT_BISON_WERROR_MSG[' >> experr
+
+          # Finish building expected stderr and check.  Unlike warnings,
+          # complaints cause bison to exit early.  Thus, with -Werror, bison
+          # does not necessarily report all warnings that it does without
+          # -Werror, but it at least reports one.
+          at_bison_check_last="`sed -n '$=' stderr`"
+          if test x"$at_bison_check_last" = x; then
+            at_bison_check_last=1
+          fi
+          at_bison_check_last="`expr $at_bison_check_last - 1`"
+          sed -n "$at_bison_check_first,$at_bison_check_last"p \
+            at-bison-check-warnings >> experr
+          ]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \
+                      stderr 1>&2]], [[0]], [[]], [experr])[
+
+          # Now check --warnings=error.
+          cp stderr experr
+          ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=error]],
+                    [[1]], [expout], [experr])[
+
+          # Now check -Wnone and --warnings=none by making sure -Werror
+          # doesn't change the exit status when -Wnone 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.
+          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
+            mv at-bison-check-experr.bak experr
+          fi
+          if test -f at-bison-check-stderr.bak; then
+            mv at-bison-check-stderr.bak stderr
+          fi
+        fi
+      ]])
 ])
 
 # AT_BISON_CHECK_XML(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
-- 
1.7.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]