From d864aeebbcafee66306e8f74b58d49fa97922cf3 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 24 Nov 2014 08:34:01 +0000 Subject: [PATCH] trans.c (build_return_expr): Use INIT_EXPR instead of MODIFY_EXPR to assign to the return object. * 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. From-SVN: r218000 --- gcc/ada/ChangeLog | 7 +++++++ gcc/ada/gcc-interface/trans.c | 13 +++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c8568f72ee4..bd38c1180d7 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2014-11-24 Eric Botcazou + + * 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. + 2014-11-24 Eric Botcazou * gcc-interface/trans.c (push_range_check_info): Replace early test diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 11aca57239f..d4c9c85a989 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -3135,7 +3135,7 @@ finalize_nrv_r (tree *tp, int *walk_subtrees, void *data) 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_subtrees, void *data) /* 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 ret_val) RETURN_EXPR | - MODIFY_EXPR + INIT_EXPR / \ / \ RET_OBJ ... @@ -3446,13 +3446,14 @@ build_return_expr (tree ret_obj, tree ret_val) 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, -- 2.30.2