bison-patches
[Top][All Lists]
Advanced

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

[PATCH 1/5] warnings: specify warnings categories


From: Victor Santet
Subject: [PATCH 1/5] warnings: specify warnings categories
Date: Fri, 29 Jun 2012 15:22:09 +0200

We create a function to print warnings categories, like -Werror, -Wyacc,
-Wother, ect...

* src/complain.c, src/complain.h (print_warning_categories): New function.
* src/output.c (ARRAY_CARDINALITY): Move it to file 'src/system.h'.
---
 src/complain.c |   26 +++++++++++++++++++++++++-
 src/getargs.c  |    1 -
 src/output.c   |    2 --
 src/reader.c   |    6 +++---
 src/system.h   |    1 +
 5 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/complain.c b/src/complain.c
index 933b402..5d9c55c 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -34,7 +34,31 @@ warnings warnings_flag = Wconflicts_sr | Wconflicts_rr | 
Wother;
 bool complaint_issued;
 static unsigned *indent_ptr = 0;
 
-
+static void
+warnings_print_categories (int warn_flags)
+{
+  char const *warn_names[] =
+    {
+      "error",
+      "midrule-values",
+      "yacc",
+      "conflicts-sr",
+      "conflicts-rr",
+      "other"
+    };
+
+  size_t array_length = ARRAY_CARDINALITY (warn_names);
+  bool any = false;
+  int i, mask;
+  for (i = 0, mask = 1; i < array_length; ++i, mask <<= 1)
+    if (warn_flags & mask)
+      {
+        fprintf (stderr, "%s-W%s", any ? ", " : " [", warn_names[i]);
+        any = true;
+      }
+  if (any)
+    fprintf (stderr, "]");
+}
 
 /** Report an error message.
  *
diff --git a/src/getargs.c b/src/getargs.c
index f5d3767..8596958 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -251,7 +251,6 @@ static const int warnings_types[] =
 
 ARGMATCH_VERIFY (warnings_args, warnings_types);
 
-
 /*-------------------------------------------.
 | Display the help message and exit STATUS.  |
 `-------------------------------------------*/
diff --git a/src/output.c b/src/output.c
index 723870d..d656097 100644
--- a/src/output.c
+++ b/src/output.c
@@ -42,8 +42,6 @@
 #include "symtab.h"
 #include "tables.h"
 
-# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
-
 static struct obstack format_obstack;
 
 
diff --git a/src/reader.c b/src/reader.c
index 53b21ef..59e56c5 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -129,10 +129,10 @@ record_merge_function_type (int merger, uniqstr type, 
location declaration_loc)
   if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
     {
       complain_at (declaration_loc, complaint,
-                _("result type clash on merge function %s: <%s> != <%s>"),
-                quote (merge_function->name), type, merge_function->type);
+                   _("result type clash on merge function %s: <%s> != <%s>"),
+                   quote (merge_function->name), type, merge_function->type);
       complain_at (merge_function->type_declaration_location, complaint,
-                _("previous declaration"));
+                   _("previous declaration"));
     }
   merge_function->type = uniqstr_new (type);
   merge_function->type_declaration_location = declaration_loc;
diff --git a/src/system.h b/src/system.h
index 0d69e93..5613a92 100644
--- a/src/system.h
+++ b/src/system.h
@@ -39,6 +39,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
 #define STREQ(L, R)  (strcmp(L, R) == 0)
 #define STRNEQ(L, R) (!STREQ(L, R))
 
-- 
1.7.9.5




reply via email to

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