On Mon, Apr 01, 2019 at 10:15:11AM +0200, Andreas Schwab wrote:
> On Mär 28 2019, Marek Polacek <pola...@redhat.com> wrote:
> 
> > Andreas, could you please find out why we're not hitting this code in
> > digest_init_r:
> >
> > 1210       tree elt = CONSTRUCTOR_ELT (stripped_init, 0)->value;
> > 1211       if (reference_related_p (type, TREE_TYPE (elt)))
> 
> This is never executed if flag_checking is false, of course.

It's certainly wrong for a warning to depend on flag_checking, so this
patch corrects it, and I hope will fix the ia64 problem as well.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2019-04-01  Marek Polacek  <pola...@redhat.com>

        * typeck2.c (digest_init_r): Don't condition the object slicing warning
        on flag_checking.

diff --git gcc/cp/typeck2.c gcc/cp/typeck2.c
index fa98b1cb8b5..55b84f043f4 100644
--- gcc/cp/typeck2.c
+++ gcc/cp/typeck2.c
@@ -1200,8 +1200,7 @@ digest_init_r (tree type, tree init, int nested, int 
flags,
   /* "If T is a class type and the initializer list has a single
      element of type cv U, where U is T or a class derived from T,
      the object is initialized from that element."  */
-  if (flag_checking
-      && cxx_dialect >= cxx11
+  if (cxx_dialect >= cxx11
       && BRACE_ENCLOSED_INITIALIZER_P (stripped_init)
       && CONSTRUCTOR_NELTS (stripped_init) == 1
       && ((CLASS_TYPE_P (type) && !CLASSTYPE_NON_AGGREGATE (type))
@@ -1228,7 +1227,7 @@ digest_init_r (tree type, tree init, int nested, int 
flags,
                              "results in object slicing", TREE_TYPE (field)))
                inform (loc, "remove %<{ }%> around initializer");
            }
-         else
+         else if (flag_checking)
            /* We should have fixed this in reshape_init.  */
            gcc_unreachable ();
        }

Reply via email to