This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] Small adjustment to return construct
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 24 Nov 2014 09:32:09 +0100
- Subject: [Ada] Small adjustment to return construct
- Authentication-results: sourceware.org; auth=none
This slightly improves the way the returns are built in gigi.
Tested on x86_64-suse-linux, applied on the mainline.
2014-11-24 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (build_return_expr): Use INIT_EXPR instead of
MODIFY_EXPR to assign to the return object.
(finalize_nrv_r): Adjust to above change.
(finalize_nrv_unc_r): Likewise.
--
Eric Botcazou
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c (revision 217998)
+++ gcc-interface/trans.c (working copy)
@@ -3135,7 +3135,7 @@ finalize_nrv_r (tree *tp, int *walk_subt
nop, but differs from using NULL_TREE in that it indicates that we care
about the value of the RESULT_DECL. */
else if (TREE_CODE (t) == RETURN_EXPR
- && TREE_CODE (TREE_OPERAND (t, 0)) == MODIFY_EXPR)
+ && TREE_CODE (TREE_OPERAND (t, 0)) == INIT_EXPR)
{
tree ret_val = TREE_OPERAND (TREE_OPERAND (t, 0), 1), init_expr;
@@ -3224,7 +3224,7 @@ finalize_nrv_unc_r (tree *tp, int *walk_
/* Change RETURN_EXPRs of NRVs to assign to the RESULT_DECL only the final
return value built by the allocator instead of the whole construct. */
else if (TREE_CODE (t) == RETURN_EXPR
- && TREE_CODE (TREE_OPERAND (t, 0)) == MODIFY_EXPR)
+ && TREE_CODE (TREE_OPERAND (t, 0)) == INIT_EXPR)
{
tree ret_val = TREE_OPERAND (TREE_OPERAND (t, 0), 1);
@@ -3437,7 +3437,7 @@ build_return_expr (tree ret_obj, tree re
RETURN_EXPR
|
- MODIFY_EXPR
+ INIT_EXPR
/ \
/ \
RET_OBJ ...
@@ -3446,13 +3446,14 @@ build_return_expr (tree ret_obj, tree re
of the RET_OBJ as the operation type. */
tree operation_type = TREE_TYPE (ret_obj);
- /* Convert the right operand to the operation type. Note that it's the
- same transformation as in the MODIFY_EXPR case of build_binary_op,
+ /* Convert the right operand to the operation type. Note that this is
+ the transformation applied in the INIT_EXPR case of build_binary_op,
with the assumption that the type cannot involve a placeholder. */
if (operation_type != TREE_TYPE (ret_val))
ret_val = convert (operation_type, ret_val);
- result_expr = build2 (MODIFY_EXPR, void_type_node, ret_obj, ret_val);
+ /* We always can use an INIT_EXPR for the return object. */
+ result_expr = build2 (INIT_EXPR, void_type_node, ret_obj, ret_val);
/* If the function returns an aggregate type, find out whether this is
a candidate for Named Return Value. If so, record it. Otherwise,