diff --git a/libtcc.c b/libtcc.c index f8547a81..b8ae60b7 100644 --- a/libtcc.c +++ b/libtcc.c @@ -542,9 +542,9 @@ static void error1(int mode, const char *fmt, va_list ap) tcc_exit_state(); if (mode == ERROR_WARN) { - if (s1->warn_none) + if (s1->warn_mask & WARN_DISABLED) return; - if (s1->warn_mask & (WARN_ERROR << WARN_ERROR_SHIFT)) + if (s1->warn_mask & WARN_ERROR_MASK) /* XXX individual ignorance */ mode = ERROR_ERROR; } @@ -1976,12 +1976,12 @@ reparse: } break; case TCC_OPTION_W: - s->warn_none = 0; + s->warn_mask &= ~WARN_DISABLED; if (optarg[0] && set_W_flag(s, optarg) < 0) goto unsupported_option; break; case TCC_OPTION_w: - s->warn_none = 1; + s->warn_mask |= WARN_DISABLED; break; case TCC_OPTION_rdynamic: s->rdynamic = 1; diff --git a/tcc.c b/tcc.c index e868281d..f2915a39 100644 --- a/tcc.c +++ b/tcc.c @@ -36,7 +36,7 @@ static const char help[] = " -std=c99 Conform to the ISO 1999 C standard (default).\n" " -std=c11 Conform to the ISO 2011 C standard.\n" " -Wwarning set or reset (with 'no-' prefix) 'warning' (see tcc -hh)\n" - " -w disable all warnings\n" + " -w disable all warnings and their consequences\n" " --version -v show version\n" " -vv show search paths or loaded files\n" " -h -hh show this, show more help\n" @@ -101,12 +101,12 @@ static const char help2[] = " -dt with -run/-E: auto-define 'test_...' macros\n" "Ignored options:\n" " --param -pedantic -pipe -s -traditional\n" - "-W... warnings:\n" + "-W[no-]... warnings:\n" " all turn on some (*) warnings\n" - " error stop after first warning\n" - " unsupported warn about ignored options, pragmas, etc.\n" - " write-strings strings are const\n" - " implicit-function-declaration warn for missing prototype (*)\n" + " error[=(X)] error out after first warning (for X)\n" + " unsupported warn for ignored options, pragmas,.. (X)\n" + " write-strings strings are const (*,X)\n" + " implicit-function-declaration warn for missing prototype (*,X)\n" "-f[no-]... flags:\n" " unsigned-char default char is unsigned\n" " signed-char default char is signed\n" diff --git a/tcc.h b/tcc.h index cacd1381..c8ecbc84 100644 --- a/tcc.h +++ b/tcc.h @@ -744,10 +744,16 @@ enum warn_option { WARN_GCC_COMPAT = 1u<<1, WARN_WRITE_STRINGS = 1u<<2, WARN_IMPLICIT_FUNCTION_DECLARATION = 1u<<3, - WARN_ERROR = 1u<<4, /* Not really as such in warn area, here only "MAX" */ - WARN_ALL = WARN_ERROR - 1 + /* _ERROR is in lower as "max", there is no warning for it */ + WARN_ERROR = 1u<<4, + WARN_ALL = WARN_ERROR - 1, + /* Is neither in lower nor upper: disables warnings and errors (-w) */ + WARN_DISABLED = WARN_ERROR << 1 +}; +enum { + WARN_ERROR_SHIFT = 16u, + WARN_ERROR_MASK = (WARN_ALL | WARN_ERROR) << WARN_ERROR_SHIFT }; -enum {WARN_ERROR_SHIFT = 16u}; struct TCCState { unsigned char verbose; /* if true, display some information during compilation */ @@ -779,7 +785,6 @@ struct TCCState { unsigned char dollars_in_identifiers; /* allows '$' char in identifiers */ unsigned char ms_bitfields; /* if true, emulate MS algorithm for aligning bitfields */ - unsigned char warn_none; /* NEED_WARNING(SELF,X) used to drive W[[no-]error]=X */ uint32_t warn_mask; #define NEED_WARNING(SELF,SWITCH) \