https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org --- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Patch: --- a/gcc/c-family/c-gimplify.cc +++ b/gcc/c-family/c-gimplify.cc @@ -712,13 +712,17 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED, /* 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_EXPR_DECL (*expr_p)) - && !DECL_EXTERNAL (DECL_EXPR_DECL (*expr_p)) - && !TREE_STATIC (DECL_EXPR_DECL (*expr_p)) - && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL (*expr_p)) - && !warn_init_self) - suppress_warning (DECL_EXPR_DECL (*expr_p), OPT_Winit_self); - break; + { + tree &decl = DECL_EXPR_DECL (*expr_p); + if (VAR_P (decl) + && !DECL_EXTERNAL (decl) + && !TREE_STATIC (decl) + && (DECL_INITIAL (decl) + && tree_strip_nop_conversions (DECL_INITIAL (decl)) == decl) + && !warn_init_self) + suppress_warning (decl, OPT_Winit_self); + break; + } case PREINCREMENT_EXPR: case PREDECREMENT_EXPR: