/* TODO non-arithmetic types */
if(is_type_arithmetic(type_left) && is_type_arithmetic(type_right)) {
+ if (warning.sign_compare &&
+ (expression->expression.kind != EXPR_BINARY_EQUAL &&
+ expression->expression.kind != EXPR_BINARY_NOTEQUAL) &&
+ (is_type_signed(type_left) != is_type_signed(type_right))) {
+ warningf(expression->expression.source_position,
+ "comparison between signed and unsigned");
+ }
type_t *arithmetic_type = semantic_arithmetic(type_left, type_right);
expression->left = create_implicit_cast(left, arithmetic_type);
expression->right = create_implicit_cast(right, arithmetic_type);
.missing_prototypes = false,
.redundant_decls = true,
.s_are_errors = false,
+ .shadow = false,
+ .sign_compare = false,
.strict_prototypes = true,
.switch_default = false,
.unknown_pragmas = true,
#define SET(y) warning.y = state;
#define OPT(x, y) OPTX(x) SET(y)
OPTX("all") {
+ /* Note: this switched on a lot of more warnings than gcc's -Wall */
SET(char_subscripts)
SET(check_format)
SET(empty_statement)
SET(implicit_int)
SET(main)
SET(redundant_decls)
+ SET(shadow)
+ SET(sign_compare)
SET(strict_prototypes)
SET(switch_default)
SET(unknown_pragmas)
OPT("missing-declarations", missing_declarations)
OPT("missing-prototypes", missing_prototypes)
OPT("redundant-decls", redundant_decls)
+ OPT("shadow", shadow)
+ OPT("sign-compare", sign_compare)
OPT("strict-prototypes", strict_prototypes)
OPT("switch-default", switch_default)
OPT("unknown-pragmas", unknown_pragmas)
bool s_are_errors:1; /**< Treat warnings as errors */
#if 0 // TODO
bool sequence_point:1; /**< Warn about code that may have undefined semantics because of violations of sequence point rules */
+#endif
bool shadow:1; /**< Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed */
bool sign_compare:1; /**< Warn when a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned */
+#if 0 // TODO
bool strict_aliasing:1; /**< Warn about code which might break the strict aliasing rules that the compiler is using for optimization. */
#endif
bool strict_prototypes:1; /**< Warn if a function declaration has an unspecified parameter list */