diff options
author | Martin Liska <mliska@suse.cz> | 2022-08-16 10:06:14 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-08-16 10:06:14 +0200 |
commit | 091222fb0aaa09dcf90f2bc747f1d8a6a8ef1575 (patch) | |
tree | 07de02401c3374395a453724c4163d769c02e644 /gcc/c | |
parent | b629a7958faf817ef658e3ce59183bfb9ccefe96 (diff) | |
parent | 1c596391e150a6b0c55960c1c1cf1da76ea78230 (diff) | |
download | gcc-091222fb0aaa09dcf90f2bc747f1d8a6a8ef1575.zip gcc-091222fb0aaa09dcf90f2bc747f1d8a6a8ef1575.tar.gz gcc-091222fb0aaa09dcf90f2bc747f1d8a6a8ef1575.tar.bz2 |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/c/c-parser.cc | 19 |
2 files changed, 24 insertions, 4 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index b5ecf92..985c96c 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2022-08-11 Marek Polacek <polacek@redhat.com> + + PR middle-end/102633 + * c-parser.cc (c_parser_initializer): Add new tree parameter. Use it. + Call suppress_warning. + (c_parser_declaration_or_fndef): Pass d down to c_parser_initializer. + (c_parser_omp_declare_reduction): Pass omp_priv down to + c_parser_initializer. + 2022-08-08 Tom Honermann <tom@honermann.net> * c-parser.cc (c_parser_string_literal): Use char8_t as the type diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index fa93959..759f200 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -1521,7 +1521,7 @@ static struct c_arg_info *c_parser_parms_list_declarator (c_parser *, tree, 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 *); @@ -2286,7 +2286,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, 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 (); } @@ -5211,11 +5211,13 @@ c_parser_type_name (c_parser *parser, bool alignas_ok) 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); @@ -5224,6 +5226,15 @@ c_parser_initializer (c_parser *parser) 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); @@ -22588,7 +22599,7 @@ c_parser_omp_declare_reduction (c_parser *parser, enum pragma_context context) 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); |