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("-Winit-self", "Ignored (gcc compatibility)");
print_warning_opt_help();
}
} else if (streq(option + 1, "no-trigraphs")
|| streq(option + 1, "undef")) {
add_flag(&cppflags_obst, "%s", arg);
+ } else if (streq(option+1, "init-self")) {
+ /* ignored (gcc compatibility) */
} else {
set_warning_opt(&option[1]);
}
/** Point to the current function declaration if inside a function. */
static function_t *current_function = NULL;
static entity_t *current_entity = NULL;
-static entity_t *current_init_decl = NULL;
static switch_statement_t *current_switch = NULL;
static statement_t *current_loop = NULL;
static statement_t *current_parent = NULL;
static label_statement_t **label_anchor = NULL;
/** current translation unit. */
static translation_unit_t *unit = NULL;
-/** true if we are in a type property context (evaluation only for type) */
-static bool in_type_prop = false;
/** true if we are in an __extension__ context. */
static bool in_gcc_extension = false;
static struct obstack temp_obst;
expression_t *expression = NULL;
- bool old_type_prop = in_type_prop;
- in_type_prop = true;
-
switch (token.type) {
case T_IDENTIFIER:
if (is_typedef_symbol(token.symbol)) {
}
break;
}
- in_type_prop = old_type_prop;
rem_anchor_token(')');
expect(')', end_error);
env.type = orig_type;
env.must_be_constant = must_be_constant;
env.entity = entity;
- current_init_decl = entity;
initializer_t *initializer = parse_initializer(&env);
- current_init_decl = NULL;
if (entity->kind == ENTITY_VARIABLE) {
/* ยง6.7.5:22 array initializers for arrays with unknown size
check_deprecated(&pos, entity);
- if (entity == current_init_decl && !in_type_prop && entity->kind == ENTITY_VARIABLE) {
- current_init_decl = NULL;
- warningf(WARN_INIT_SELF, &pos, "variable '%#N' is initialized by itself", entity);
- }
-
return expression;
}
eat(kind == EXPR_SIZEOF ? T_sizeof : T___alignof__);
- /* we only refer to a type property, mark this case */
- bool old = in_type_prop;
- in_type_prop = true;
-
type_t *orig_type;
expression_t *expression;
if (token.type == '(' && is_declaration_specifier(look_ahead(1))) {
}
end_error:
- in_type_prop = old;
return tp_expression;
}
[WARN_FORMAT] = { WARN_STATE_ON, "format" },
[WARN_IMPLICIT_FUNCTION_DECLARATION] = { WARN_STATE_ON, "implicit-function-declaration" },
[WARN_IMPLICIT_INT] = { WARN_STATE_ON, "implicit-int" },
- [WARN_INIT_SELF] = { WARN_STATE_ON, "init-self", },
[WARN_LONG_LONG] = { WARN_STATE_NONE, "long-long" },
[WARN_MAIN] = { WARN_STATE_ON, "main", },
[WARN_MISSING_DECLARATIONS] = { WARN_STATE_NONE, "missing-declarations", },
SET(WARN_FORMAT);
SET(WARN_IMPLICIT_FUNCTION_DECLARATION);
SET(WARN_IMPLICIT_INT);
- SET(WARN_INIT_SELF);
SET(WARN_MAIN);
SET(WARN_MISSING_DECLARATIONS);
SET(WARN_NONNULL);
WARN_FORMAT, /**< Check printf-style format strings */
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 */
- WARN_INIT_SELF, /**< Warn about uninitialized variables which are initialized with themselves. */
#if 0 // TODO
WARN_INLINE, /**< Warn if a function can not be inlined and it was declared as inline */
WARN_INT_TO_POINTER_CAST, /**< Warn if cast from integer to pointer of different size. */