diff options
| -rw-r--r-- | evaluate.c | 25 | ||||
| -rw-r--r-- | lib.c | 4 | ||||
| -rw-r--r-- | lib.h | 1 |
3 files changed, 22 insertions, 8 deletions
@@ -542,13 +542,24 @@ const char * type_difference(struct symbol *target, struct symbol *source, if (diff & ~MOD_SIGNEDNESS) return "different modifiers"; - /* Differs in signedness only.. Sometimes ok - but not if both are explicit */ - if ((mod1 | mod2) & MOD_EXPLICITLY_SIGNED) - return "different explicit signedness"; - - /* "char" matches both "unsigned char" and "signed char" */ - if (!(mod1 & MOD_CHAR)) - return "different signedness"; + /* Differs in signedness only.. */ + if (Wtypesign) { + /* + * Warn if both are explicitly signed ("unsigned" is obvously + * always explicit, and since we know one of them has to be + * unsigned, we check if the signed one was explicit). + */ + if ((mod1 | mod2) & MOD_EXPLICITLY_SIGNED) + return "different explicit signedness"; + + /* + * "char" matches both "unsigned char" and "signed char", + * so if the explicit test didn't trigger, then we should + * not warn about a char. + */ + if (!(mod1 & MOD_CHAR)) + return "different signedness"; + } } if (type1 == SYM_FN) { @@ -561,6 +561,7 @@ unsigned char pre_buffer[8192]; int Wdefault_bitfield_sign = 0; int Wbitwise = 0; +int Wtypesign = 0; int preprocess_only; char *include; int include_fd = -1; @@ -669,7 +670,8 @@ struct warning { int *flag; } warnings[] = { { "default-bitfield-sign", &Wdefault_bitfield_sign }, - { "bitwise", &Wbitwise } + { "bitwise", &Wbitwise }, + { "typesign", &Wtypesign }, }; @@ -139,6 +139,7 @@ extern char *include; extern int preprocess_only; extern int Wdefault_bitfield_sign; extern int Wbitwise; +extern int Wtypesign; extern void create_builtin_stream(void); |
