static struct c_parm *c_parser_parameter_declaration (c_parser *, tree, bool);
static tree c_parser_simple_asm_expr (c_parser *);
static tree c_parser_gnu_attributes (c_parser *);
-static struct c_expr c_parser_initializer (c_parser *);
+static struct c_expr c_parser_initializer (c_parser *, tree);
static struct c_expr c_parser_braced_init (c_parser *, tree, bool,
struct obstack *);
static void c_parser_initelt (c_parser *, struct obstack *);
int flag_sanitize_save = flag_sanitize;
if (TREE_CODE (d) == PARM_DECL)
flag_sanitize = 0;
- init = c_parser_initializer (parser);
+ init = c_parser_initializer (parser, d);
flag_sanitize = flag_sanitize_save;
finish_init ();
}
Any expression without commas is accepted in the syntax for the
constant-expressions, with non-constant expressions rejected later.
+ DECL is the declaration we're parsing this initializer for.
+
This function is only used for top-level initializers; for nested
ones, see c_parser_initval. */
static struct c_expr
-c_parser_initializer (c_parser *parser)
+c_parser_initializer (c_parser *parser, tree decl)
{
if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
return c_parser_braced_init (parser, NULL_TREE, false, NULL);
struct c_expr ret;
location_t loc = c_parser_peek_token (parser)->location;
ret = c_parser_expr_no_commas (parser, NULL);
+ /* This is handled mostly by gimplify.cc, but we have to deal with
+ not warning about int x = x; as it is a GCC extension to turn off
+ this warning but only if warn_init_self is zero. */
+ if (VAR_P (decl)
+ && !DECL_EXTERNAL (decl)
+ && !TREE_STATIC (decl)
+ && ret.value == decl
+ && !warn_init_self)
+ suppress_warning (decl, OPT_Winit_self);
if (TREE_CODE (ret.value) != STRING_CST
&& TREE_CODE (ret.value) != COMPOUND_LITERAL_EXPR)
ret = convert_lvalue_to_rvalue (loc, ret, true, true);
location_t loc = c_parser_peek_token (parser)->location;
rich_location richloc (line_table, loc);
start_init (omp_priv, NULL_TREE, 0, &richloc);
- struct c_expr init = c_parser_initializer (parser);
+ struct c_expr init = c_parser_initializer (parser, omp_priv);
finish_init ();
finish_decl (omp_priv, loc, init.value,
init.original_type, NULL_TREE);