Commit d864aeeb by Eric Botcazou Committed by Eric Botcazou

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
parent 90b4c164
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.
2014-11-24 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (push_range_check_info): Replace early test
with assertion.
(Raise_Error_to_gnu): Do not call push_range_check_info if the loop
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment