diff options
author | Jason Merrill <jason@redhat.com> | 2021-01-13 13:27:06 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2021-01-15 13:57:01 -0500 |
commit | d75199f782348bfc401f925b60f33ffc9822b7cc (patch) | |
tree | a1f67748fa7024d5816a2133f7e9310101d70f0a /gcc/tree-ssanames.c | |
parent | 424deca72b63e644cbc975cbc2fdda5248449bcb (diff) | |
download | gcc-d75199f782348bfc401f925b60f33ffc9822b7cc.zip gcc-d75199f782348bfc401f925b60f33ffc9822b7cc.tar.gz gcc-d75199f782348bfc401f925b60f33ffc9822b7cc.tar.bz2 |
c++: Avoid redundant copy in {} init [PR98642]
Here, initializing from { } implies a call to the default constructor for
base. We were then seeing that we're initializing a base subobject, so we
tried to copy the result of that call. This is clearly wrong; we should
initialize the base directly from its default constructor.
This patch does a lot of refactoring of unsafe_copy_elision_p and adds
make_safe_copy_elision that will also try to do the base constructor
rewriting from the last patch.
gcc/cp/ChangeLog:
PR c++/98642
* call.c (unsafe_return_slot_p): Return int.
(init_by_return_slot_p): Split out from...
(unsafe_copy_elision_p): ...here.
(unsafe_copy_elision_p_opt): New name for old meaning.
(build_over_call): Adjust.
(make_safe_copy_elision): New.
* typeck2.c (split_nonconstant_init_1): Elide copy from safe
list-initialization.
* cp-tree.h: Adjust.
gcc/testsuite/ChangeLog:
PR c++/98642
* g++.dg/cpp1z/elide5.C: New test.
Diffstat (limited to 'gcc/tree-ssanames.c')
0 files changed, 0 insertions, 0 deletions