Accept -W as alias for -Wextra.
authorChristoph Mallon <christoph.mallon@gmx.de>
Wed, 15 Jun 2011 16:46:37 +0000 (18:46 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Wed, 15 Jun 2011 16:46:37 +0000 (18:46 +0200)
cparser.1
main.c
warning.c

index f68901d..3470227 100644 (file)
--- a/cparser.1
+++ b/cparser.1
@@ -147,6 +147,8 @@ Treat warnings as errors, i.e. do not continue after parsing when a warning is e
 .It Fl Werror-implicit-function-declaration
 Generate an error, when calling a function without a prior declaration.
 .It Fl Wextra
+(Alias
+.Fl W Ns )
 Activate some more warnings.
 In particular these are
 .Fl Wempty-statement ,
diff --git a/main.c b/main.c
index 1c8cfd0..190f932 100644 (file)
--- a/main.c
+++ b/main.c
@@ -634,7 +634,6 @@ static void print_help_parser(void)
 static void print_help_warnings(void)
 {
        put_help("-w",                       "disable all warnings");
-       put_help("-W",                       "ignored (gcc compatibility)");
        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();
@@ -1135,9 +1134,7 @@ int main(int argc, char **argv)
                                        }
                                }
                        } else if (option[0] == 'W') {
-                               if (option[1] == '\0') {
-                                       /* ignore -W, our defaults are already quite verbose */
-                               } else if (strstart(option + 1, "p,")) {
+                               if (strstart(option + 1, "p,")) {
                                        // pass options directly to the preprocessor
                                        const char *opt;
                                        GET_ARG_AFTER(opt, "-Wp,");
index 9b09d2c..044af8d 100644 (file)
--- a/warning.c
+++ b/warning.c
@@ -147,7 +147,9 @@ void set_warning_opt(const char *const opt)
                state = false;
        }
 
-       if (0) {}
+       if (s[0] == '\0') { // -W is an alias for -Wextra
+               goto extra;
+       }
 #define OPTX(x)   else if (strcmp(s, x) == 0)
 #define SET(y)    (void)(warning.y = state)
 #define OPT(x, y) OPTX(x) SET(y)
@@ -197,6 +199,7 @@ void set_warning_opt(const char *const opt)
        OPT("error",                               s_are_errors);
        OPT("error-implicit-function-declaration", error_implicit_function_declaration);
        OPTX("extra") {
+extra:
                /* TODO */
                // TODO SET(function_end_without_return);
                SET(empty_statement);