c++: NRV and ref-extended temps [PR101442]
commitad8161e6d7b26d690d90069ae9a129e7ac36892a
authorJason Merrill <jason@redhat.com>
Wed, 13 Apr 2022 17:23:08 +0000 (13 13:23 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 14 Apr 2022 00:22:57 +0000 (13 20:22 -0400)
tree8397db198a89d837de235775f3b6223a3fd3a32b
parent019d6d4149ee97d55ce9efe4e5e470d38130cdeb
c++: NRV and ref-extended temps [PR101442]

This issue goes back to r83221, where the cleanup for extended ref temps
changed from being unconditional to being tied to the declaration they
formed part of the initializer for.

The named return value optimization changes the cleanup for the NRV variable
to only run on the EH path; we don't want that change to affect temporary
cleanups.  The perform_member_init change isn't necessary (there 'decl' is a
COMPONENT_REF), it's just for consistency.

PR c++/101442

gcc/cp/ChangeLog:

* decl.cc (cp_finish_decl): Don't pass decl to push_cleanup.
* init.cc (perform_member_init): Likewise.
* semantics.cc (push_cleanup): Adjust comment.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist-nrv1.C: New test.
gcc/cp/decl.cc
gcc/cp/init.cc
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/cpp0x/initlist-nrv1.C [new file with mode: 0644]