public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Hans-Peter Nilsson <hp@axis.com>
To: Jason Merrill <jason@redhat.com>
Cc: <gcc-patches@gcc.gnu.org>
Subject: Re: [pushed] c++: allow NRV and non-NRV returns [PR58487]
Date: Fri, 9 Jun 2023 02:42:51 +0200	[thread overview]
Message-ID: <20230609004251.836A92043D@pchp3.se.axis.com> (raw)
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)

> Date: Wed,  7 Jun 2023 18:06:15 -0400
> From: Jason Merrill via Gcc-patches <gcc-patches@gcc.gnu.org>

> 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

      reply	other threads:[~2023-06-09  0:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07 22:06 Jason Merrill
2023-06-09  0:42 ` Hans-Peter Nilsson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230609004251.836A92043D@pchp3.se.axis.com \
    --to=hp@axis.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).