Support -Wall flag
PATCH 1/1 Support -Wall flag
From: Pavel Roskin <[email protected]>
If -Wall is specified, enable all warnings except those explicitly disabled by -Wno-* switches.
Signed-off-by Pavel Roskin <[email protected]>
---
lib.c | 30 +++++++++++++++++++++++++++--- 1 files changed, 27 insertions(+), 3 deletions(-)
lib.c +27 -3
@@ -325,24 +325,37 @@ static const struct warning { { "shadow", &Wshadow }, }; +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; } }
@@ -351,6 +364,16 @@ static char **handle_switch_W(char *arg,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 ;
@@ -608,6 +631,7 @@ struct symbol_list *sparse_initialize(in*/ argv[files++] = arg; } +handle_switch_W_finalize (); list =NULL ; argv[files] =NULL ;
Josh Triplett
AppliedQuoted 2 lines · Pavel Roskin
If -Wall is specified, enable all warnings except those explicitly disabled by -Wno-* switches.
Applied, and thanks! Sorry this slipped through the cracks.
- Josh Triplett