Warnings in system headers are suppressed by default now.
Like
.Fl Wshadow ,
but only warn if the shadowed declaration is not global, e.g. a local variable shadows a parameter or another local variable.
+.It Fl Wsystem
+Show warnings in system headers.
+By default, no warnings in system headers are shown.
.It Fl Wunreachable-code
Warn when the compiler determines that a statement (or in some cases a part thereof) will never be executed.
.It Fl Wunused
void warningf(warning_t const warn, position_t const* pos, char const *const fmt, ...)
{
+ if (pos->is_system_header && !is_warn_on(WARN_SYSTEM))
+ return;
+
va_list ap;
va_start(ap, fmt);
warning_switch_t const *const s = get_warn_switch(warn);
decl->attributes);
if (has_new_attrs) {
merge_in_attributes(decl, prev_decl->attributes);
- } else if (!is_definition &&
- is_type_valid(prev_type) &&
- !pos->is_system_header) {
+ } else if (!is_definition && is_type_valid(prev_type)) {
warningf(WARN_REDUNDANT_DECLS, pos, "redundant declaration for '%N' (declared %P)", entity, ppos);
}
} else if (current_function == NULL) {
[WARN_STRICT_PROTOTYPES] = { WARN_STATE_ON, "strict-prototypes" },
[WARN_SWITCH_DEFAULT] = { WARN_STATE_NONE, "switch-default", },
[WARN_SWITCH_ENUM] = { WARN_STATE_NONE, "switch-enum", },
+ [WARN_SYSTEM] = { WARN_STATE_NONE, "system", },
[WARN_TRADITIONAL] = { WARN_STATE_NONE, "traditional" },
[WARN_UNINITIALIZED] = { WARN_STATE_ON, "uninitialized", },
[WARN_UNKNOWN_PRAGMAS] = { WARN_STATE_ON, "unknown-pragmas", },
WARN_STRICT_PROTOTYPES, /**< Warn if a function declaration has an unspecified parameter list */
WARN_SWITCH_DEFAULT, /**< Warn whenever a 'switch' statement does not have a 'default' case */
WARN_SWITCH_ENUM, /**< Warn about 'switch' statements with an enum as index type and missing case labels or case labels outside the enum range TODO has an alias -Wswitch? */
+ WARN_SYSTEM, /**< Show warnings in system headers. */
WARN_TRADITIONAL, /**< Warn about certain constructs that behave differently in traditional and ISO C */
#if 0 // TODO
WARN_UNDEF, /**< Warn if an undefined identifier is evaluated in an '#if' directive */