@@ -2057,7 +2057,8 @@ static struct symbol *evaluate_sizeof(struct expression *expr)
}
if (size == 1 && is_bool_type(type)) {
- warning(expr->pos, "expression using sizeof bool");
+ if (Wsizeof_bool)
+ warning(expr->pos, "expression using sizeof bool");
size = bits_in_char;
}
@@ -226,6 +226,7 @@ int Wparen_string = 0;
int Wptr_subtraction_blows = 0;
int Wreturn_void = 0;
int Wshadow = 0;
+int Wsizeof_bool = 1;
int Wtransparent_union = 0;
int Wtypesign = 0;
int Wundef = 0;
@@ -438,6 +439,7 @@ static const struct warning {
{ "ptr-subtraction-blows", &Wptr_subtraction_blows },
{ "return-void", &Wreturn_void },
{ "shadow", &Wshadow },
+ { "sizeof-bool", &Wsizeof_bool },
{ "transparent-union", &Wtransparent_union },
{ "typesign", &Wtypesign },
{ "undef", &Wundef },
@@ -120,6 +120,7 @@ extern int Wparen_string;
extern int Wptr_subtraction_blows;
extern int Wreturn_void;
extern int Wshadow;
+extern int Wsizeof_bool;
extern int Wtransparent_union;
extern int Wtypesign;
extern int Wundef;
@@ -297,6 +297,15 @@ Such declarations can lead to error-prone code.
Sparse does not issue these warnings by default.
.
.TP
+.B \-Wsizeof-bool
+Warn when checking the sizeof a _Bool.
+
+C99 does not specify the sizeof a _Bool. gcc uses 1.
+
+Sparse issues these warnings by default. To turn them off, use
+\fB\-Wno\-sizeof\-bool\fR.
+.
+.TP
.B \-Wtransparent\-union
Warn about any declaration using the GCC extension
\fB__attribute__((transparent_union))\fR.