bison-patches
[Top][All Lists]
Advanced

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

finish implementing --warnings=error


From: Joel E. Denny
Subject: finish implementing --warnings=error
Date: Tue, 31 Oct 2006 20:47:45 -0500 (EST)

I committed this.

Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1596
diff -p -u -r1.1596 ChangeLog
--- ChangeLog   31 Oct 2006 22:24:57 -0000      1.1596
+++ ChangeLog   1 Nov 2006 01:42:21 -0000
@@ -1,5 +1,21 @@
 2006-10-31  Joel E. Denny  <address@hidden>
 
+       Finish implementing --warnings=error, which should not be implied by
+       --warnings=all (or by its synonyms -W and --warnings without
+       subarguments).
+       * src/complain.c (set_warning_issued): New function to report that
+       warnings are being treated as errors and to record an error if so.
+       Invoke...
+       (warn_at, warn): ... here.
+       * src/getargs.c (warnings_args, warnings_types): Reorder so that
+       "error - warnings are errors" does not appear above "all - all of the
+       above".
+       (getargs): For -W and --warnings without subarguments, don't let
+       FLAGS_ARGMATCH set warnings_error in warnings_flag.
+       * src/getargs.h (enum warnings): Unset warnings_error in warnings_all.
+
+2006-10-31  Joel E. Denny  <address@hidden>
+
        * src/getargs.c (flags_argmatch): Don't cause segmentation fault for
        empty subargument list.  For example: `bison  --warnings=  parser.y'.
 
Index: src/complain.c
===================================================================
RCS file: /sources/bison/bison/src/complain.c,v
retrieving revision 1.24
diff -p -u -r1.24 complain.c
--- src/complain.c      10 Jul 2006 19:36:31 -0000      1.24
+++ src/complain.c      1 Nov 2006 01:42:21 -0000
@@ -28,6 +28,7 @@
 
 #include "complain.h"
 #include "files.h"
+#include "getargs.h"
 
 /* The calling program should define program_name and set it to the
    name of the executing program.  */
@@ -79,15 +80,29 @@ error_message (location *loc,
 | Report a warning, and proceed.  |
 `--------------------------------*/
 
+static void
+set_warning_issued (void)
+{
+  static bool warning_issued = false;
+  if (!warning_issued && (warnings_flag & warnings_error))
+    {
+      fprintf (stderr, "%s: warnings being treated as errors\n", program_name);
+      complaint_issued = true;
+    }
+  warning_issued = true;
+}
+
 void
 warn_at (location loc, const char *message, ...)
 {
+  set_warning_issued ();
   ERROR_MESSAGE (&loc, _("warning"), message);
 }
 
 void
 warn (const char *message, ...)
 {
+  set_warning_issued ();
   ERROR_MESSAGE (NULL, _("warning"), message);
 }
 
Index: src/getargs.c
===================================================================
RCS file: /sources/bison/bison/src/getargs.c,v
retrieving revision 1.82
diff -p -u -r1.82 getargs.c
--- src/getargs.c       31 Oct 2006 22:24:57 -0000      1.82
+++ src/getargs.c       1 Nov 2006 01:42:21 -0000
@@ -204,18 +204,18 @@ static const char * const warnings_args[
   /* In a series of synonyms, present the most meaningful first, so
      that argmatch_valid be more readable.  */
   "none       - no warnings",
-  "error      - warnings are errors",
   "yacc       - incompatibilities with POSIX YACC",
   "all        - all of the above",
+  "error      - warnings are errors",
   0
 };
 
 static const int warnings_types[] =
 {
   warnings_none,
-  warnings_error,
   warnings_yacc,
-  warnings_all
+  warnings_all,
+  warnings_error
 };
 
 ARGMATCH_VERIFY (warnings_args, warnings_types);
@@ -472,7 +472,10 @@ getargs (int argc, char *argv[])
        break;
 
       case 'W':
-       FLAGS_ARGMATCH (warnings, optarg);
+       if (optarg)
+         FLAGS_ARGMATCH (warnings, optarg);
+       else
+         warnings_flag |= warnings_all;
        break;
 
       case LOCATIONS_OPTION:
Index: src/getargs.h
===================================================================
RCS file: /sources/bison/bison/src/getargs.h,v
retrieving revision 1.34
diff -p -u -r1.34 getargs.h
--- src/getargs.h       15 Sep 2006 15:56:26 -0000      1.34
+++ src/getargs.h       1 Nov 2006 01:42:21 -0000
@@ -112,7 +112,7 @@ enum warnings
     warnings_none             = 0,      /**< Issue no warnings.  */
     warnings_error            = 1 << 0, /**< Warnings are treated as errors.  
*/
     warnings_yacc             = 1 << 1, /**< POSIXME.  */
-    warnings_all              = ~0      /**< All of the above.  */
+    warnings_all              = ~warnings_error /**< All above warnings.  */
   };
 /** What warnings are issued.  */
 extern int warnings_flag;




reply via email to

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