On 5/23/24 20:32, Marek Polacek wrote:
On Thu, May 23, 2024 at 04:04:13PM -0400, Jason Merrill wrote:
On 5/23/24 10:41, Marek Polacek wrote:
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
-- >8 --
Coming back to our discussion in
<https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649426.html>:
TARGET_EXPRs that initialize a function argument are not marked
TARGET_EXPR_ELIDING_P even though gimplify_arg drops such TARGET_EXPRs
on the floor.
But only if TREE_TYPE (TARGET_EXPR_INITIAL is non-void, I think we should
check that here too to be parallel.
Ah yes, definitely.
Perhaps most/all affected TARGET_EXPRs will have been handled earlier in the
function under the TREE_ADDRESSABLE check, but I wouldn't rely on that
without an assert.
So like this or you want an assert somewhere too? dg.exp passed.
-- >8 --
Coming back to our discussion in
<https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649426.html>:
TARGET_EXPRs that initialize a function argument are not marked
TARGET_EXPR_ELIDING_P even though gimplify_arg drops such TARGET_EXPRs
on the floor. To work around it, I added a pset to
replace_placeholders_for_class_temp_r, but it would be best to just rely
on TARGET_EXPR_ELIDING_P.
PR c++/114707
gcc/cp/ChangeLog:
* call.cc (convert_for_arg_passing): Call set_target_expr_eliding.
* typeck2.cc (replace_placeholders_for_class_temp_r): Don't use pset.
(digest_nsdmi_init): Call cp_walk_tree_without_duplicates instead of
cp_walk_tree.
---
gcc/cp/call.cc | 6 ++++++
gcc/cp/typeck2.cc | 20 ++++----------------
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index ed68eb3c568..35c024f2c7c 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -9437,6 +9437,12 @@ convert_for_arg_passing (tree type, tree val,
tsubst_flags_t complain)
if (complain & tf_warning)
warn_for_address_of_packed_member (type, val);
+ /* gimplify_arg elides TARGET_EXPRs that initialize a function argument. */
+ if (TREE_CODE (val) == TARGET_EXPR)
+ if (tree init = TARGET_EXPR_INITIAL (val))
+ if (!VOID_TYPE_P (TREE_TYPE (init)))
You can simplify this test to 'if (SIMPLE_TARGET_EXPR_P ...'. OK with
that change.
Jason