+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
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;
/* 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);
RETURN_EXPR
|
- MODIFY_EXPR
+ INIT_EXPR
/ \
/ \
RET_OBJ ...
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,