aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/utils2.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2005-10-21 15:46:19 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2005-10-21 15:46:19 +0000
commit552725e3bd542d98dd0f4a830c602230fff7138c (patch)
tree6f247edb01a5d6b87e8e3c910f200eaeb6643429 /gcc/ada/utils2.c
parent6058b2fa2cc5799e442cc8c7a02bff0b170b6025 (diff)
downloadgcc-552725e3bd542d98dd0f4a830c602230fff7138c.zip
gcc-552725e3bd542d98dd0f4a830c602230fff7138c.tar.gz
gcc-552725e3bd542d98dd0f4a830c602230fff7138c.tar.bz2
re PR ada/21937 (Member record alignment triggers an ICE)
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. From-SVN: r105741
Diffstat (limited to 'gcc/ada/utils2.c')
-rw-r--r--gcc/ada/utils2.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/gcc/ada/utils2.c b/gcc/ada/utils2.c
index 5847910..21a3f61 100644
--- a/gcc/ada/utils2.c
+++ b/gcc/ada/utils2.c
@@ -1378,8 +1378,50 @@ build_cond_expr (tree result_type, tree condition_operand,
return result;
}
-
+/* Similar, but for RETURN_EXPR. If RESULT_DECL is non-zero, build
+ a RETURN_EXPR around the assignment of RET_VAL to RESULT_DECL.
+ If RESULT_DECL is zero, build a bare RETURN_EXPR. */
+
+tree
+build_return_expr (tree result_decl, tree ret_val)
+{
+ tree result_expr;
+
+ if (result_decl)
+ {
+ /* The gimplifier explicitly enforces the following invariant:
+
+ RETURN_EXPR
+ |
+ MODIFY_EXPR
+ / \
+ / \
+ RESULT_DECL ...
+
+ As a consequence, type-homogeneity dictates that we use the type
+ of the RESULT_DECL as the operation type. */
+
+ tree operation_type = TREE_TYPE (result_decl);
+
+ /* 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 with the additional guarantee that the type
+ cannot involve a placeholder, since otherwise the function
+ would use the "target pointer" return mechanism. */
+
+ if (operation_type != TREE_TYPE (ret_val))
+ ret_val = convert (operation_type, ret_val);
+
+ result_expr
+ = build2 (MODIFY_EXPR, operation_type, result_decl, ret_val);
+ }
+ else
+ result_expr = NULL_TREE;
+
+ return build1 (RETURN_EXPR, void_type_node, result_expr);
+}
+
/* Build a CALL_EXPR to call FUNDECL with one argument, ARG. Return
the CALL_EXPR. */