diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-10-21 15:46:19 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-10-21 15:46:19 +0000 |
commit | 3ee3365e10c582543d864e13588280d0b9996373 (patch) | |
tree | 6f247edb01a5d6b87e8e3c910f200eaeb6643429 /gcc/ada/trans.c | |
parent | 330b3f362eef725566322e984db5566b062515ff (diff) | |
download | gcc-3ee3365e10c582543d864e13588280d0b9996373.tar.gz |
PR ada/21937
PR ada/22328
PR ada/22381
PR ada/22383
PR ada/22419
PR ada/22420
* utils2.c (build_return_expr): New helper function.
* gigi.h (build_return_expr): Declare it.
* trans.c (Subprogram_Body_to_gnu): Use build_return_expr instead
of manually building the RETURN_EXPR tree.
(call_to_gnu): Pass MODIFY_EXPR through build_binary_op.
(gnat_to_gnu) <N_Return_Statement>: Pass MODIFY_EXPR through
build_binary_op for the "target pointer" case. �Use build_return_expr
instead of manually building the RETURN_EXPR tree.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105741 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/trans.c')
-rw-r--r-- | gcc/ada/trans.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c index fb741a3e030..0e05b6d4731 100644 --- a/gcc/ada/trans.c +++ b/gcc/ada/trans.c @@ -1456,9 +1456,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) gnu_retval = build_unary_op (INDIRECT_REF, NULL_TREE, gnu_retval); add_stmt_with_node - (build1 (RETURN_EXPR, void_type_node, - build2 (MODIFY_EXPR, TREE_TYPE (gnu_retval), - DECL_RESULT (current_function_decl), gnu_retval)), + (build_return_expr (DECL_RESULT (current_function_decl), gnu_retval), gnat_node); gnat_poplevel (); gnu_result = end_stmt_group (); @@ -1685,8 +1683,8 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target) } /* Set up to move the copy back to the original. */ - gnu_temp = build2 (MODIFY_EXPR, TREE_TYPE (gnu_copy), - gnu_copy, gnu_actual); + gnu_temp = build_binary_op (MODIFY_EXPR, NULL_TREE, + gnu_copy, gnu_actual); annotate_with_node (gnu_temp, gnat_actual); append_to_statement_list (gnu_temp, &gnu_after_list); } @@ -3519,8 +3517,6 @@ gnat_to_gnu (Node_Id gnat_node) tree gnu_ret_val = NULL_TREE; /* The place to put the return value. */ tree gnu_lhs; - /* Avoid passing error_mark_node to RETURN_EXPR. */ - gnu_result = NULL_TREE; /* If we are dealing with a "return;" from an Ada procedure with parameters passed by copy in copy out, we need to return a record @@ -3626,18 +3622,20 @@ gnat_to_gnu (Node_Id gnat_node) } } } - - if (gnu_ret_val) - gnu_result = build2 (MODIFY_EXPR, TREE_TYPE (gnu_ret_val), - gnu_lhs, gnu_ret_val); + else + /* If the Ada subprogram is a regular procedure, just return. */ + gnu_lhs = NULL_TREE; if (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type)) { + if (gnu_ret_val) + gnu_result = build_binary_op (MODIFY_EXPR, NULL_TREE, + gnu_lhs, gnu_ret_val); add_stmt_with_node (gnu_result, gnat_node); - gnu_result = NULL_TREE; + gnu_lhs = NULL_TREE; } - gnu_result = build1 (RETURN_EXPR, void_type_node, gnu_result); + gnu_result = build_return_expr (gnu_lhs, gnu_ret_val); } break; |