From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 127067 invoked by alias); 6 Mar 2017 16:30:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 125022 invoked by uid 89); 6 Mar 2017 16:30:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy=Hx-languages-length:1736 X-HELO: mail-ot0-f182.google.com Received: from mail-ot0-f182.google.com (HELO mail-ot0-f182.google.com) (74.125.82.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 06 Mar 2017 16:30:42 +0000 Received: by mail-ot0-f182.google.com with SMTP id i1so116399147ota.3 for ; Mon, 06 Mar 2017 08:30:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NfA2REeIJ1NRmoz3PywegdpWF9pJwhwYsbbtx6cSN+s=; b=P4lyhY9ff2Z+oOq8kBSNqRF7ho+EICJQKmI20UndDDkwoVlB3BROh9KlozDu3agZmB KrMbMJydCdZlTMqqtrQ3pUpG5eS6alpJkqnZzMyy1tsYU4kXAKy2+31K1LENFHReRDXo 94uA3+86qXWk52fpXHJBt8SuMYv7b37Fu/Sixu5RQRUn5woYig2oPep4uHfeEhBQ+Ki4 nYJG/bPV3oLvtqqnM1DaaEQ1TlvP608WnAjw80S3yl67Y0C7R3i+G2pTxcqd2TvkGm7k A5U0fuNtUHARr69ELFB50mkM5X8av8WVSqp3FYKMegWTZ6bik60uo+4aZienFWYaeYCc kdEQ== X-Gm-Message-State: AMke39mRS0KFOJoBM+SUlvKGHC5H12b/NX8DHPgGZs5++255HHjZ551RMNhJLCF3fuBhqy3y30VHfx0ZCvKuXWw7 X-Received: by 10.157.33.85 with SMTP id l21mr9667035otd.217.1488817841691; Mon, 06 Mar 2017 08:30:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.187.8 with HTTP; Mon, 6 Mar 2017 08:30:21 -0800 (PST) In-Reply-To: <20170303163411.GQ3172@redhat.com> References: <20170303163411.GQ3172@redhat.com> From: Jason Merrill Date: Mon, 06 Mar 2017 16:30:00 -0000 Message-ID: Subject: Re: C++ PATCH to fix ICE with NSDMI and this pointer (PR c++/79796) To: Marek Polacek Cc: GCC Patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00262.txt.bz2 OK. On Fri, Mar 3, 2017 at 6:34 AM, Marek Polacek 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 > > 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