diff options
author | Patrick Palka <ppalka@redhat.com> | 2021-05-26 08:37:30 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2021-05-26 08:37:30 -0400 |
commit | 88834c7d05acf5ce4eaccda56fb04436595e2a52 (patch) | |
tree | 1e568bdbd5eacf4883a7a5df569add056eeb8442 /gcc/function.h | |
parent | b4329e3dd6fb7c78948fcf9d2f5b9d873deec284 (diff) | |
download | gcc-88834c7d05acf5ce4eaccda56fb04436595e2a52.zip gcc-88834c7d05acf5ce4eaccda56fb04436595e2a52.tar.gz gcc-88834c7d05acf5ce4eaccda56fb04436595e2a52.tar.bz2 |
c++: constexpr and copy elision within mem init [PR100368]
In the testcase below, the member initializer b(f()) inside C's default
constructor is encoded as a TARGET_EXPR wrapping the CALL_EXPR f() in
C++17 mode. During massaging of this constexpr constructor,
build_target_expr_with_type called from bot_manip on this initializer
tries to add an extra copy using B's implicitly deleted copy constructor
rather than just preserving the copy elision.
Since it's wrong to introduce an extra copy when initializing a
temporary from a CALL_EXPR, this patch makes build_target_expr_with_type
avoid calling force_rvalue in this case. Additionally, bot_manip should
be copying TARGET_EXPRs in a more oblivious manner, so this patch makes
bot_manip use force_target_expr instead of build_target_expr_with_type.
And since bot_manip is now no longer a caller, we can remove the void
initializer handling in build_target_expr_with_type.
PR c++/100368
gcc/cp/ChangeLog:
* tree.c (build_target_expr_with_type): Don't call force_rvalue
on CALL_EXPR initializer. Simplify now that bot_manip is no
longer a caller.
(bot_manip): Use force_target_expr instead of
build_target_expr_with_type.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/elide6.C: New test.
Diffstat (limited to 'gcc/function.h')
0 files changed, 0 insertions, 0 deletions