diff options
author | Jason Merrill <jason@redhat.com> | 2005-06-23 10:44:21 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2005-06-23 10:44:21 -0400 |
commit | fa47911c5600725d7d72e224e4a61829267b00b9 (patch) | |
tree | 672b804a497a6d4d52b747f00969c6d7b30ebbfb /gcc/cp | |
parent | f565b0a1a58554b7dd3cbd540f6dca295bd0cdbe (diff) | |
download | gcc-fa47911c5600725d7d72e224e4a61829267b00b9.zip gcc-fa47911c5600725d7d72e224e4a61829267b00b9.tar.gz gcc-fa47911c5600725d7d72e224e4a61829267b00b9.tar.bz2 |
re PR c++/19317 (removing a temporary return value when we cannot)
PR c++/19317
Leave the return slot target in the MODIFY_EXPR rather than making
it an argument, but only use it if the CALL_EXPR has a flag set.
* tree.h (CALL_EXPR_HAS_RETURN_SLOT_ADDR): Rename to
CALL_EXPR_RETURN_SLOT_OPT.
* calls.c (expand_call): Adjust.
* tree-inline.c (expand_call_inline): Adjust.
* tree-pretty-print.c (dump_generic_node): Adjust.
And set the flag as appropriate.
* gimplify.c (gimplify_modify_expr_rhs): Set
CALL_EXPR_HAS_RETURN_SLOT_ADDR where the LHS is obviously safe.
* tree-nrv.c (execute_return_slot_opt): Set
CALL_EXPR_HAS_RETURN_SLOT_ADDR based on escape analysis.
* tree-pass.h: Declare pass_return_slot.
* tree-optimize.c (init_tree_optimization_passes): Add it.
* cp/semantics.c (simplify_aggr_init_expr): Use
CALL_EXPR_RETURN_SLOT_OPT, not CALL_EXPR_HAS_RETURN_SLOT_ADDR.
From-SVN: r101269
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 31 |
2 files changed, 18 insertions, 19 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d6fc512..61b8a03 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-06-23 Jason Merrill <jason@redhat.com> + + PR c++/19317 + * semantics.c (simplify_aggr_init_expr): Use + CALL_EXPR_RETURN_SLOT_OPT, not CALL_EXPR_HAS_RETURN_SLOT_ADDR. + 2005-06-23 Volker Reichelt <reichelt@igpm.rwth-aachen.de> * pt.c (register_specialization): Remove superfluous assertion. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 0c55975..157ec9c 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2904,27 +2904,15 @@ simplify_aggr_init_expr (tree *tp) style = arg; } - if (style == ctor || style == arg) + if (style == ctor) { - /* Pass the address of the slot. If this is a constructor, we - replace the first argument; otherwise, we tack on a new one. */ + /* Replace the first argument to the ctor with the address of the + slot. */ tree addr; - if (style == ctor) - args = TREE_CHAIN (args); - + args = TREE_CHAIN (args); cxx_mark_addressable (slot); addr = build1 (ADDR_EXPR, build_pointer_type (type), slot); - if (style == arg) - { - /* The return type might have different cv-quals from the slot. */ - tree fntype = TREE_TYPE (TREE_TYPE (fn)); - - gcc_assert (TREE_CODE (fntype) == FUNCTION_TYPE - || TREE_CODE (fntype) == METHOD_TYPE); - addr = convert (build_pointer_type (TREE_TYPE (fntype)), addr); - } - args = tree_cons (NULL_TREE, addr, args); } @@ -2933,9 +2921,13 @@ simplify_aggr_init_expr (tree *tp) fn, args, NULL_TREE); if (style == arg) - /* Tell the backend that we've added our return slot to the argument - list. */ - CALL_EXPR_HAS_RETURN_SLOT_ADDR (call_expr) = 1; + { + /* Just mark it addressable here, and leave the rest to + expand_call{,_inline}. */ + cxx_mark_addressable (slot); + CALL_EXPR_RETURN_SLOT_OPT (call_expr) = true; + call_expr = build2 (MODIFY_EXPR, TREE_TYPE (call_expr), slot, call_expr); + } else if (style == pcc) { /* If we're using the non-reentrant PCC calling convention, then we @@ -2945,6 +2937,7 @@ simplify_aggr_init_expr (tree *tp) call_expr = build_aggr_init (slot, call_expr, DIRECT_BIND | LOOKUP_ONLYCONVERTING); pop_deferring_access_checks (); + call_expr = build (COMPOUND_EXPR, TREE_TYPE (slot), call_expr, slot); } *tp = call_expr; |