aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--evaluate.c25
-rw-r--r--lib.c4
-rw-r--r--lib.h1
3 files changed, 22 insertions, 8 deletions
diff --git a/evaluate.c b/evaluate.c
index 65e5d5a2..e4391941 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -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) {
diff --git a/lib.c b/lib.c
index a2c3c2c4..5d15706f 100644
--- a/lib.c
+++ b/lib.c
@@ -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 },
};
diff --git a/lib.h b/lib.h
index fb5db185..bcbcab04 100644
--- a/lib.h
+++ b/lib.h
@@ -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);