OK.
On Fri, Mar 3, 2017 at 6:34 AM, Marek Polacek <pola...@redhat.com> wrote: > We weren't replacing PLACEHOLDER_EXPR in the following testcase, leading to a > crash in the gimplifier. The fix seems to be to use replace_placeholders, the > question is where. These three functions have it: > cp_gimplify_init_expr > store_init_value > build_new_1 > But we call neither so I tried adding the call to build_over_call, right > after we create the MODIFY_EXPR with the NSDMI, and that seemed to work > out. > > Bootstrapped/regtested on x86_64-linux, ok for trunk? > > 2017-03-03 Marek Polacek <pola...@redhat.com> > > PR c++/79796 - ICE with NSDMI and this pointer > * call.c (build_over_call): Handle NSDMI with a 'this' by calling > replace_placeholders. > > * g++.dg/cpp0x/nsdmi13.C: New test. > > diff --git gcc/cp/call.c gcc/cp/call.c > index dc629b96..b821224 100644 > --- gcc/cp/call.c > +++ gcc/cp/call.c > @@ -8047,6 +8047,9 @@ build_over_call (struct z_candidate *cand, int flags, > tsubst_flags_t complain) > { > arg = cp_build_indirect_ref (arg, RO_NULL, complain); > val = build2 (MODIFY_EXPR, TREE_TYPE (to), to, arg); > + if (cxx_dialect >= cxx14) > + /* Handle NSDMI that refer to the object being initialized. */ > + replace_placeholders (arg, to); > } > else > { > diff --git gcc/testsuite/g++.dg/cpp0x/nsdmi13.C > gcc/testsuite/g++.dg/cpp0x/nsdmi13.C > index e69de29..2751da3 100644 > --- gcc/testsuite/g++.dg/cpp0x/nsdmi13.C > +++ gcc/testsuite/g++.dg/cpp0x/nsdmi13.C > @@ -0,0 +1,13 @@ > +// PR c++/79796 > +// { dg-do compile { target c++11 } } > + > +struct A > +{ > + A* p = this; > +}; > + > +void foo() > +{ > + A a; > + a = A({}); > +} > > Marek