-W[no-]error: fix previous

This commit is contained in:
Steffen Nurpmeso 2021-07-27 20:00:20 +02:00
parent 0c16762418
commit 0d59ac4817
2 changed files with 4 additions and 5 deletions

View File

@ -544,7 +544,7 @@ static void error1(int mode, const char *fmt, va_list ap)
if (mode == ERROR_WARN) { if (mode == ERROR_WARN) {
if (s1->warn_none) if (s1->warn_none)
return; return;
if (s1->warn_error) if (s1->warn_mask & (WARN_ERROR << WARN_ERROR_SHIFT))
mode = ERROR_ERROR; mode = ERROR_ERROR;
} }
@ -1288,7 +1288,7 @@ ST_FUNC int set_W_flag(TCCState *s, const char *optarg)
char const *name; char const *name;
} const opts[] = { } const opts[] = {
{WARN_ALL, 0, "all"}, {WARN_ALL, 0, "all"},
{WARN_ERROR, 0, "error"}, {WARN_ERROR | (WARN_ERROR << WARN_ERROR_SHIFT), 0, "error"},
{WARN_UNSUPPORTED, WD_ERROR, "unsupported"}, {WARN_UNSUPPORTED, WD_ERROR, "unsupported"},
{WARN_GCC_COMPAT, WD_ERROR, "gcc-compat"}, {WARN_GCC_COMPAT, WD_ERROR, "gcc-compat"},
{WARN_WRITE_STRINGS, WD_ERROR | WD_ALL, "write-strings"}, {WARN_WRITE_STRINGS, WD_ERROR | WD_ALL, "write-strings"},

5
tcc.h
View File

@ -744,7 +744,7 @@ enum warn_option {
WARN_GCC_COMPAT = 1u<<1, WARN_GCC_COMPAT = 1u<<1,
WARN_WRITE_STRINGS = 1u<<2, WARN_WRITE_STRINGS = 1u<<2,
WARN_IMPLICIT_FUNCTION_DECLARATION = 1u<<3, WARN_IMPLICIT_FUNCTION_DECLARATION = 1u<<3,
WARN_ERROR = 1u<<4, WARN_ERROR = 1u<<4, /* Not really as such in warn area, here only "MAX" */
WARN_ALL = WARN_ERROR - 1 WARN_ALL = WARN_ERROR - 1
}; };
enum {WARN_ERROR_SHIFT = 16u}; enum {WARN_ERROR_SHIFT = 16u};
@ -780,14 +780,13 @@ struct TCCState {
unsigned char ms_bitfields; /* if true, emulate MS algorithm for aligning bitfields */ unsigned char ms_bitfields; /* if true, emulate MS algorithm for aligning bitfields */
unsigned char warn_none; unsigned char warn_none;
unsigned char warn_error;
/* NEED_WARNING(SELF,X) used to drive W[[no-]error]=X */ /* NEED_WARNING(SELF,X) used to drive W[[no-]error]=X */
uint32_t warn_mask; uint32_t warn_mask;
#define NEED_WARNING(SELF,SWITCH) \ #define NEED_WARNING(SELF,SWITCH) \
(((SELF)->warn_mask & \ (((SELF)->warn_mask & \
(WARN_ ## SWITCH | (WARN_ ## SWITCH << WARN_ERROR_SHIFT))) \ (WARN_ ## SWITCH | (WARN_ ## SWITCH << WARN_ERROR_SHIFT))) \
? (((SELF)->warn_mask & (WARN_ ## SWITCH << WARN_ERROR_SHIFT)) \ ? (((SELF)->warn_mask & (WARN_ ## SWITCH << WARN_ERROR_SHIFT)) \
? (SELF)->warn_error = 1 : 1) : 0) ? (SELF)->warn_mask |= (WARN_ERROR << WARN_ERROR_SHIFT), 1 : 1) : 0)
/* compile with debug symbol (and use them if error during execution) */ /* compile with debug symbol (and use them if error during execution) */
unsigned char do_debug; unsigned char do_debug;