summaryrefslogtreecommitdiff
path: root/src/complain.c
diff options
context:
space:
mode:
authorAkim Demaille <akim@lrde.epita.fr>2013-02-11 10:25:08 +0100
committerAkim Demaille <akim@lrde.epita.fr>2013-02-14 15:00:51 +0100
commit219458e22f163ede84daa71dfa98bab82a766954 (patch)
tree892920b1b48fdd671ebfeb7bbc8d22c367053634 /src/complain.c
parentfec5f3c0cc2c50a779dafb928fda105c1782446b (diff)
downloadbison-219458e22f163ede84daa71dfa98bab82a766954.tar.gz
diagnostics: factor the list of warning names
* src/getargs.h, src/getargs.c (warnings_args, warnings_types): Make them public. * src/complain.h, src/complain.c (warnings_print_categories): Its only use outside complain.c was removed in a recent commit, so make it static. Simplify its implementation. Use warnings_args and warnings_types. * src/muscle-tab.c (muscle_percent_define_check_values): Make it silent.
Diffstat (limited to 'src/complain.c')
-rw-r--r--src/complain.c44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/complain.c b/src/complain.c
index f9b2fead..80731b72 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -38,35 +38,20 @@ warnings errors_flag;
err_status complaint_status = status_none;
static unsigned *indent_ptr = 0;
-void
-warnings_print_categories (warnings warn_flags)
+/** Display a "[-Wyacc]" like message on \a f. */
+
+static void
+warnings_print_categories (warnings warn_flags, FILE *f)
{
- if (! (warn_flags & silent))
- {
- char const *warn_names[] =
- {
- "midrule-values",
- "yacc",
- "conflicts-sr",
- "conflicts-rr",
- "deprecated",
- "precedence",
- "other"
- };
-
- bool any = false;
- int i;
- for (i = 0; i < ARRAY_CARDINALITY (warn_names); ++i)
- if (warn_flags & 1 << i)
- {
- bool err = warn_flags & errors_flag;
- fprintf (stderr, "%s-W", any ? ", " : " [");
- fprintf (stderr, "%s%s", err ? "error=" : "" , warn_names[i]);
- any = true;
- }
- if (any)
- fprintf (stderr, "]");
- }
+ /* Display only the first match, the second is "-Wall". */
+ int i;
+ for (i = 0; warnings_args[i]; ++i)
+ if (warn_flags & warnings_types[i])
+ {
+ bool err = warn_flags & errors_flag;
+ fprintf (f, " [-W%s%s]", err ? "error=" : "" , warnings_args[i]);
+ break;
+ }
}
/** Report an error message.
@@ -109,7 +94,8 @@ error_message (const location *loc, warnings flags, const char *prefix,
fprintf (stderr, "%s: ", prefix);
vfprintf (stderr, message, args);
- warnings_print_categories (flags);
+ if (! (flags & silent))
+ warnings_print_categories (flags, stderr);
{
size_t l = strlen (message);
if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ')