From 5e7a92300a348e8a47bb488cd19be626346d6460 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 1 Aug 2006 13:50:08 -0400 Subject: [PATCH] Support -Wall flag If -Wall is specified, enable all warnings except those explicitly disabled by -Wno-* switches. Signed-off-by: Pavel Roskin --- lib.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/lib.c b/lib.c index 171ce594..51c415d2 100644 --- a/lib.c +++ b/lib.c @@ -342,24 +342,37 @@ static const struct warning { { "uninitialized", &Wuninitialized }, }; +enum { + WARNING_OFF, + WARNING_ON, + WARNING_FORCE_OFF +}; + static char **handle_switch_W(char *arg, char **next) { - int no = 0; + int flag = WARNING_ON; char *p = arg + 1; unsigned i; + if (!strcmp(p, "all")) { + for (i = 0; i < sizeof(warnings) / sizeof(warnings[0]); i++) { + if (*warnings[i].flag != WARNING_FORCE_OFF) + *warnings[i].flag = WARNING_ON; + } + } + // Prefixes "no" and "no-" mean to turn warning off. if (p[0] == 'n' && p[1] == 'o') { p += 2; if (p[0] == '-') p++; - no = 1; + flag = WARNING_FORCE_OFF; } for (i = 0; i < sizeof(warnings) / sizeof(warnings[0]); i++) { if (!strcmp(p,warnings[i].name)) { - *warnings[i].flag = !no; + *warnings[i].flag = flag; return next; } } @@ -368,6 +381,16 @@ static char **handle_switch_W(char *arg, char **next) return next; } +static void handle_switch_W_finalize(void) +{ + unsigned i; + + for (i = 0; i < sizeof(warnings) / sizeof(warnings[0]); i++) { + if (*warnings[i].flag == WARNING_FORCE_OFF) + *warnings[i].flag = WARNING_OFF; + } +} + static char **handle_switch_U(char *arg, char **next) { const char *name = arg + 1; @@ -632,6 +655,7 @@ struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list } add_ptr_list_notag(filelist, arg); } + handle_switch_W_finalize(); list = NULL; if (!ptr_list_empty(filelist)) { -- 2.11.4.GIT