put_help("-w", "Disable all warnings");
put_help("-Wno-trigraphs", "Warn if input contains trigraphs");
put_help("-Wundef", "Warn if an undefined macro is used in an #if");
+ put_help("-Wmissing-include-dirs", "Warn about missing user-specified include directories");
+ put_help("-Wendif-labels", "Warn about stray text after #elif and #endif");
put_help("-Winit-self", "Ignored (gcc compatibility)");
+ put_help("-Wformat-y2k", "Ignored (gcc compatibility)");
+ put_help("-Wformat-security", "Ignored (gcc compatibility)");
+ put_help("-Wold-style-declaration", "Ignored (gcc compatibility)");
+ put_help("-Wtype-limits", "Ignored (gcc compatibility)");
print_warning_opt_help();
}
streq(opt, "align-loops") ||
streq(opt, "align-jumps") ||
streq(opt, "align-functions") ||
- streq(opt, "PIC")) {
+ streq(opt, "PIC") ||
+ streq(opt, "stack-protector") ||
+ streq(opt, "stack-protector-all")) {
fprintf(stderr, "ignoring gcc option '-f%s'\n", orig_opt);
} else {
int res = firm_option(orig_opt);
GET_ARG_AFTER(opt, "-Wl,");
add_flag(&ldflags_obst, "-Wl,%s", opt);
} else if (streq(option + 1, "no-trigraphs")
- || streq(option + 1, "undef")) {
+ || streq(option + 1, "undef")
+ || streq(option + 1, "missing-include-dirs")
+ || streq(option + 1, "endif-labels")) {
add_flag(&cppflags_obst, "%s", arg);
} else if (streq(option+1, "init-self")) {
- /* ignored (gcc compatibility) */
+ /* ignored (asme as gcc does) */
+ } else if (streq(option+1, "format-y2k")
+ || streq(option+1, "format-security")
+ || streq(option+1, "old-style-declaration")
+ || streq(option+1, "type-limits")) {
+ /* ignore (gcc compatibility) */
} else {
set_warning_opt(&option[1]);
}
errorf(pos, "function returning array is not allowed");
} else {
if (skipped_return_type->base.qualifiers != 0) {
- warningf(WARN_OTHER, pos, "type qualifiers in return type of function type are meaningless");
+ warningf(WARN_IGNORED_QUALIFIERS, pos, "type qualifiers in return type of function type are meaningless");
}
}
statement->ifs.true_statement = true_stmt;
rem_anchor_token(T_else);
+ if (true_stmt->kind == STATEMENT_EMPTY) {
+ warningf(WARN_EMPTY_BODY, HERE,
+ "suggest braces around empty body in an ‘if’ statement");
+ }
+
if (next_if(T_else)) {
statement->ifs.false_statement = parse_inner_statement();
+
+ if (statement->ifs.false_statement->kind == STATEMENT_EMPTY) {
+ warningf(WARN_EMPTY_BODY, HERE,
+ "suggest braces around empty body in an ‘if’ statement");
+ }
} else if (true_stmt->kind == STATEMENT_IF &&
true_stmt->ifs.false_statement != NULL) {
source_position_t const *const pos = &true_stmt->base.source_position;
[WARN_DECLARATION_AFTER_STATEMENT] = { WARN_STATE_NONE, "declaration-after-statement", },
[WARN_DEPRECATED_DECLARATIONS] = { WARN_STATE_ON, "deprecated-declarations", },
[WARN_DIV_BY_ZERO] = { WARN_STATE_ON, "div-by-zero", },
+ [WARN_EMPTY_BODY] = { WARN_STATE_NONE, "empty-body", },
[WARN_EMPTY_STATEMENT] = { WARN_STATE_NONE, "empty-statement", },
[WARN_ERROR] = { WARN_STATE_NONE, "error" },
[WARN_FATAL_ERRORS] = { WARN_STATE_NONE, "fatal-errors" },
[WARN_FLOAT_EQUAL] = { WARN_STATE_NONE, "float-equal", },
[WARN_FORMAT] = { WARN_STATE_ON, "format" },
+ [WARN_IGNORED_QUALIFIERS] = { WARN_STATE_ON, "ignored-qualifiers" },
[WARN_IMPLICIT_FUNCTION_DECLARATION] = { WARN_STATE_ON, "implicit-function-declaration" },
[WARN_IMPLICIT_INT] = { WARN_STATE_ON, "implicit-int" },
[WARN_LONG_LONG] = { WARN_STATE_NONE, "long-long" },
WARN_DECLARATION_AFTER_STATEMENT, /**< Warn when a declaration is found after a statement in a block */
WARN_DEPRECATED_DECLARATIONS, /* TODO implement for types */ /**< Warn about uses of functions, variables and types marked as deprecated by using the 'deprecated' attribute */
WARN_DIV_BY_ZERO, /**< Warn about compile-time integer division by zero */
+ WARN_EMPTY_BODY, /**< Warn about an empty body of an if or else statement */
WARN_EMPTY_STATEMENT, /**< Warn about empty statements, i.e. lone ';' */
#if 0 // TODO
WARN_ENDIF_LABELS, /**< Warn whenever an '#else' or an '#endif' are followed by text */
WARN_FATAL_ERRORS, /**< First error stops the compilation */
WARN_FLOAT_EQUAL, /**< Warn if floating point values are used in equality comparisons */
WARN_FORMAT, /**< Check printf-style format strings */
+ WARN_IGNORED_QUALIFIERS, /**< Warn when type qualifiers are meaningless */
WARN_IMPLICIT_FUNCTION_DECLARATION, /**< Warn whenever a function is used before being declared */
WARN_IMPLICIT_INT, /**< Warn when a declaration does not specify a type */
#if 0 // TODO