aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Hainque <hainque@adacore.com>2006-09-13 18:48:21 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2006-09-13 18:48:21 +0000
commit6f2789da074d0d9e68af0cf4bc79a64a3e552d03 (patch)
tree07363f60721190c943580bee201d42d01e2ec4d8
parentefaa616eeb3b3cc2cbe664ba9305d3035fb2d2d9 (diff)
downloadgcc-6f2789da074d0d9e68af0cf4bc79a64a3e552d03.zip
gcc-6f2789da074d0d9e68af0cf4bc79a64a3e552d03.tar.gz
gcc-6f2789da074d0d9e68af0cf4bc79a64a3e552d03.tar.bz2
re PR ada/29025 (procedure doesn't modify In Out parameter)
PR ada/29025 * trans.c (gnat_gimplify_expr) <ADDR_EXPR>: When taking the address of a SAVE_EXPR, just make the operand addressable/not-readonly and let the common gimplifier code make and propagate a temporary copy. (call_to_gnu): Clarify the use of SAVE_EXPR for not addressable out/in-out actuals and defer setting the addressable/readonly bits to the gimplifier. From-SVN: r116929
-rw-r--r--gcc/ada/ChangeLog10
-rw-r--r--gcc/ada/trans.c27
2 files changed, 27 insertions, 10 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 60fbf11..77cf3d31 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,13 @@
+2006-09-13 Olivier Hainque <hainque@adacore.com>
+
+ PR ada/29025
+ * trans.c (gnat_gimplify_expr) <ADDR_EXPR>: When taking the address
+ of a SAVE_EXPR, just make the operand addressable/not-readonly and
+ let the common gimplifier code make and propagate a temporary copy.
+ (call_to_gnu): Clarify the use of SAVE_EXPR for not addressable
+ out/in-out actuals and defer setting the addressable/readonly bits
+ to the gimplifier.
+
2006-09-13 Eric Botcazou <ebotcazou@adacore.com>
PR ada/28591
diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c
index b7b3598..7fecc6f 100644
--- a/gcc/ada/trans.c
+++ b/gcc/ada/trans.c
@@ -1775,18 +1775,12 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target)
&& (TYPE_JUSTIFIED_MODULAR_P (gnu_name_type)))
gnu_name = convert (gnu_name_type, gnu_name);
+ /* Make a SAVE_EXPR to both properly account for potential side
+ effects and handle the creation of a temporary copy. Special
+ code in gnat_gimplify_expr ensures that the same temporary is
+ used as the actual and copied back after the call. */
gnu_actual = save_expr (gnu_name);
- /* Since we're going to take the address of the SAVE_EXPR, we
- don't want it to be marked as unchanging. So set
- TREE_ADDRESSABLE. */
- gnu_temp = skip_simple_arithmetic (gnu_actual);
- if (TREE_CODE (gnu_temp) == SAVE_EXPR)
- {
- TREE_ADDRESSABLE (gnu_temp) = 1;
- TREE_READONLY (gnu_temp) = 0;
- }
-
/* Set up to move the copy back to the original. */
gnu_temp = build_binary_op (MODIFY_EXPR, NULL_TREE,
gnu_copy, gnu_actual);
@@ -4697,6 +4691,19 @@ gnat_gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p ATTRIBUTE_UNUSED)
return GS_ALL_DONE;
}
+ /* If we are taking the address of a SAVE_EXPR, we are typically
+ processing a misaligned argument to be passed by reference in a
+ procedure call. We just mark the operand as addressable + not
+ readonly here and let the common gimplifier code perform the
+ temporary creation, initialization, and "instantiation" in place of
+ the SAVE_EXPR in further operands, in particular in the copy back
+ code inserted after the call. */
+ else if (TREE_CODE (op) == SAVE_EXPR)
+ {
+ TREE_ADDRESSABLE (op) = 1;
+ TREE_READONLY (op) = 0;
+ }
+
/* Otherwise, if we are taking the address of something that is neither
reference, declaration, or constant, make a variable for the operand
here and then take its address. If we don't do it this way, we may