Implement -f[no-]diagnostics-show-option.
authorChristoph Mallon <christoph.mallon@gmx.de>
Wed, 22 Jun 2011 05:44:19 +0000 (07:44 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Wed, 22 Jun 2011 05:44:19 +0000 (07:44 +0200)
cparser.1
diagnostic.c
diagnostic.h
main.c

index 450b87c..87dedd2 100644 (file)
--- a/cparser.1
+++ b/cparser.1
@@ -255,6 +255,9 @@ Set a frontend or optimizer option.
 Use
 .Fl fhelp
 to get a list of supported optimizer options.
+.It Fl f Ns Oo Cm no- Oc Ns Cm diagnostics-show-option
+Show the switch, which controls a warning, after each warning.
+Default is on.
 .It Fl finput-charset= Ns Ar encoding
 Select the encoding of the input.
 Supported values are
index 5174308..b2ba266 100644 (file)
 #include "warning.h"
 
 /** Number of occurred diagnostics. */
-unsigned diagnostic_count    = 0;
+unsigned diagnostic_count        = 0;
 /** Number of occurred errors. */
-unsigned error_count         = 0;
+unsigned error_count             = 0;
 /** Number of occurred warnings. */
-unsigned warning_count       = 0;
-bool     show_column         = true;
+unsigned warning_count           = 0;
+bool     show_column             = true;
+bool     diagnostics_show_option = true;
 
 static const source_position_t *curr_pos = NULL;
 
@@ -258,7 +259,8 @@ void warningf(warning_t const warn, source_position_t const* pos, char const *co
                                kind = "warning";
                        }
                        diagnosticposvf(pos, kind, fmt, ap);
-                       fprintf(stderr, " [-W%s]\n", s->name);
+                       if (diagnostics_show_option)
+                               fprintf(stderr, " [-W%s]\n", s->name);
                        break;
 
                default:
index 313a2a9..36b57b9 100644 (file)
@@ -66,6 +66,7 @@ NORETURN internal_errorf(const source_position_t *pos, const char *fmt, ...);
 extern unsigned diagnostic_count;
 extern unsigned error_count;
 extern unsigned warning_count;
-extern bool     show_column;      /**< Show column in diagnostic messages */
+extern bool     show_column;             /**< Show column in diagnostic messages */
+extern bool     diagnostics_show_option; /**< Show the switch, which controls a warning. */
 
 #endif
diff --git a/main.c b/main.c
index 9ed9ea8..bc6a233 100644 (file)
--- a/main.c
+++ b/main.c
@@ -633,9 +633,10 @@ static void print_help_parser(void)
 
 static void print_help_warnings(void)
 {
-       put_help("-w",                       "disable all warnings");
-       put_help("-Wno-trigraphs",           "warn if input contains trigraphs");
-       put_help("-Wundef",                  "Warn if an undefined macro is used in an #if");
+       put_help("-f[no-]diagnostics-show-option", "Show the switch, which controls a warning, after each warning");
+       put_help("-w",                             "disable all warnings");
+       put_help("-Wno-trigraphs",                 "warn if input contains trigraphs");
+       put_help("-Wundef",                        "Warn if an undefined macro is used in an #if");
        print_warning_opt_help();
 }
 
@@ -1068,6 +1069,8 @@ int main(int argc, char **argv)
 
                                        if (streq(opt, "builtins")) {
                                                use_builtins = truth_value;
+                                       } else if (streq(opt, "diagnostics-show-option")) {
+                                               diagnostics_show_option = truth_value;
                                        } else if (streq(opt, "dollars-in-identifiers")) {
                                                allow_dollar_in_symbol = truth_value;
                                        } else if (streq(opt, "omit-frame-pointer")) {