From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by sourceware.org (Postfix) with ESMTPS id 155593858C20 for ; Fri, 9 Jun 2023 00:42:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 155593858C20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=axis.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1686271373; x=1717807373; h=from:to:cc:in-reply-to:subject:mime-version: content-transfer-encoding:references:message-id:date; bh=8JFHlk5t4VykHArJIiIP/G6wHDAKxvx1D0+TjOGKkVI=; b=AIfcrONdPAtAuLuRXPJn2Kh3u0D5EbiyZbCWeeMmNsl2PsIvt1cSCBCJ 2FQ6dc0EWrgWJMOyU58+Otc4EGPhBSRG7EyROoP60LxcAhjdvmfRU2Ml4 RoWTXA8D4YR/eW5uWytbVtEwGiorFDN3c27my3VuFXZLpyAwx4Lg6Kkj1 Gb+1i1aTzlA9emVAMbDNMLJYMgxiu+Ru9txzEW6obwDARE65ZVM5B9H5K OXFeno9WHBdbeIXvM7TBUObTdrtvJO6Oz5Zru/4bPg0cNOVlPofWr0bXt SUFdkGP+atsTrycHnlqlIRt89JOq/GkZx7DsETAm/wKuLN9Kfsmlyzfmf w==; From: Hans-Peter Nilsson To: Jason Merrill CC: In-Reply-To: <20230607220615.2981121-1-jason@redhat.com> (message from Jason Merrill via Gcc-patches on Wed, 7 Jun 2023 18:06:15 -0400) Subject: Re: [pushed] c++: allow NRV and non-NRV returns [PR58487] MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT References: <20230607220615.2981121-1-jason@redhat.com> Message-ID: <20230609004251.836A92043D@pchp3.se.axis.com> Date: Fri, 9 Jun 2023 02:42:51 +0200 X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > Date: Wed, 7 Jun 2023 18:06:15 -0400 > From: Jason Merrill via Gcc-patches > Tested x86_64-pc-linux-gnu, applying to trunk. > > -- 8< -- > > Now that we support NRV from an inner block, we can also support non-NRV > returns from other blocks, since once the NRV is out of scope a later return > expression can't possibly alias it. > > This fixes 58487 and half-fixes 53637: now one of the returns is elided, but > not the other. > > Fixing the remaining xfails in these testcases will require a very different > approach, probably involving a full tree/block walk from finalize_nrv, and > check_return_expr only adding to a list of potential return variables. > > PR c++/58487 > PR c++/53637 > > gcc/cp/ChangeLog: > > * cp-tree.h (INIT_EXPR_NRV_P): New. > * semantics.cc (finalize_nrv_r): Check it. > * name-lookup.h (decl_in_scope_p): Declare. > * name-lookup.cc (decl_in_scope_p): New. > * typeck.cc (check_return_expr): Allow non-NRV > returns if the NRV is no longer in scope. > > gcc/testsuite/ChangeLog: > > * g++.dg/opt/nrv26.C: New test. > * g++.dg/opt/nrv26a.C: New test. > * g++.dg/opt/nrv27.C: New test. This somehow caused 21 regressions for cris-elf in the c++ and libstdc++ testsuites. I opened PR110185 to hold the preprocessed g++.dg/cpp2a/spaceship-p1186.C. brgds, H-P