bison-patches
[Top][All Lists]
Advanced

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

Re: [PATCH 3/3] errors: don't display "warnings treated as errors"


From: Akim Demaille
Subject: Re: [PATCH 3/3] errors: don't display "warnings treated as errors"
Date: Thu, 27 Sep 2012 12:30:16 +0200

Le 27 sept. 2012 à 12:52, Theophile Ranquet a écrit :

> This line doesn't add any meaningful information anymore, the appended
> [Werror=CATEGORY] is enough to indicate the error treatment of the
> warning: it is actually more insightful, as it allows to distinguish those
> treated as errors from those that aren't.
> 
> This line is also being removed by gcc 4.8.
> 
> Note that the only action left to (set_warning_issued) was checking if
> the error bit corresponding to the warning issued was set, and that
> function was only called once. Therefore, remove it, and do it's job
> directly in the caller, (complains).
> 
> * NEWS: Document this change.
> * src/complain.c (set_warnings_issued): Remove.
> (complains): Do set_warnings_issued's job here.
> * src/complains.h: Adjust.
> * tests/input.at: Adjust.

Thanks.  I have installed a slightly different version
(NEWS and commit message are changed).

commit 46bdb8ec593ea0cfd1604b7d1253a3af1c571e6d
Author: Theophile Ranquet <address@hidden>
Date:   Thu Sep 27 10:52:47 2012 +0000

    errors: don't display "warnings treated as errors"
    
    This line doesn't add any meaningful information anymore, the appended
    [-Werror=CATEGORY] is enough.  It is actually more insightful, as it
    allows to distinguish warnings treated as errors from those that
    aren't.  This line is also removed by gcc 4.8.
    
    * src/complain.c (set_warnings_issued): The only action left was
    checking if the error bit corresponding to the warning issued was set,
    and that function was only called once. Therefore, remove it, and do
    its job directly in the caller...
    (complains): here.
    * src/complains.h: Adjust.
    * tests/input.at: Adjust.
    * NEWS: Document this change.
    
    Signed-off-by: Akim Demaille <address@hidden>

diff --git a/NEWS b/NEWS
index 1d4e0fa..ee1b095 100644
--- a/NEWS
+++ b/NEWS
@@ -39,25 +39,24 @@ GNU Bison NEWS
   Yacc-like behavior (e.g., always generate y.tab.c), but to report
   incompatibilities as warnings: "-y -Wno-error=yacc".
 
-*** Warning categories are now displayed and prefix changes
+*** The display of warnings is now richer
 
-  For instance:
+  The option that controls a given warning is now displayed:
 
-  foo.y:4.6: warning: type clash on default action: <foo> != <bar> [-Wother]
+    foo.y:4.6: warning: type clash on default action: <foo> != <bar> [-Wother]
 
-  In the case of warnings treated as errors, the suffix is displayed, in a
-  manner similar to gcc, as [-Werror=CATEGORY]. Also, the prefix is changed
-  from "warning: " to "error: ".
+  In the case of warnings treated as errors, the prefix is changed from
+  "warning: " to "error: ", and the suffix is displayed, in a manner similar
+  to gcc, as [-Werror=CATEGORY].
 
-  For instance, considering the above change, an output for -Werror=other
-  would have been:
+  For instance, where the previous version of Bison would report (and exit
+  with failure):
 
     bison: warnings being treated as errors
-    input.y:1.1: warning: stray ',' treated as white space [-Wother]
+    input.y:1.1: warning: stray ',' treated as white space
 
-  But it is actually:
+  it now reports:
 
-    bison: warnings being treated as errors
     input.y:1.1: error: stray ',' treated as white space [-Werror=other]
 
 *** Deprecated constructs
diff --git a/src/complain.c b/src/complain.c
index d4098f7..53bb5cb 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -134,9 +134,8 @@ complains (const location *loc, warnings flags, const char 
*message,
     {
       const char* prefix =
         flags & (errors_flag | complaint) ? _("error") : _("warning");
-      if (flags & complaint)
+      if (flags & (complaint | errors_flag))
         complaint_issued = true;
-      set_warning_issued (flags);
       error_message (loc, flags,
                      indent_ptr && *indent_ptr ? NULL : prefix,
                      message, args);
@@ -171,20 +170,3 @@ void complain_at_indent (location loc, warnings flags, 
unsigned *indent,
   complains (&loc, flags, message, args);
   va_end (args);
 }
-
-
-/*--------------------------------.
-| Report a warning, and proceed.  |
-`--------------------------------*/
-
-void
-set_warning_issued (warnings warning)
-{
-  static bool warning_issued = false;
-  if (!warning_issued && (warning & warnings_flag & errors_flag))
-    {
-      fprintf (stderr, "%s: warnings being treated as errors\n", program_name);
-      complaint_issued = true;
-    }
-  warning_issued = true;
-}
diff --git a/src/complain.h b/src/complain.h
index 840e736..1d47391 100644
--- a/src/complain.h
+++ b/src/complain.h
@@ -21,6 +21,9 @@
 
 # include "location.h"
 
+/* Sub-messages indent. */
+#define SUB_INDENT (4)
+
 /*-------------.
 | --warnings.  |
 `-------------*/
@@ -54,16 +57,6 @@ extern warnings errors_flag;
 /** Display a "[-Wyacc]" like message on stderr.  */
 void warnings_print_categories (warnings warn_flags);
 
-/* Sub-messages indent. */
-#define SUB_INDENT (4)
-
-/** Record that a warning is about to be issued, and treat it as an
-    error if <tt>warnings_flag & Werror</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 (warnings warning);
-
 /** Make a complaint, but don't specify any location.  */
 void complain (warnings flags, char const *message, ...)
   __attribute__ ((__format__ (__printf__, 2, 3)));
diff --git a/tests/input.at b/tests/input.at
index c149894..188ed16 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -1460,8 +1460,7 @@ AT_BISON_CHECK([[-Wno-none input.y]], [[0]], [[]],
 # -Werror is not disabled by -Wnone or equivalent.
 AT_BISON_CHECK([[-Werror,none,yacc input.y]], [[1]], [[]], [[stderr]])
 AT_CHECK([[sed 's/^.*bison:/bison:/' stderr]], [[0]],
-[[bison: warnings being treated as errors
-input.y:2.1-7: error: POSIX Yacc forbids dashes in symbol names: foo-bar 
[-Werror=yacc]
+[[input.y:2.1-7: error: POSIX Yacc forbids dashes in symbol names: foo-bar 
[-Werror=yacc]
 ]])
 [mv stderr experr]
 AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]])





reply via email to

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