aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/trans.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2015-05-26 19:18:15 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2015-05-26 19:18:15 +0000
commit7194767cdf77212e8c736f41b426e3f636f52ca3 (patch)
treef122b2e6ed989a86921cf79b73be23a226e14688 /gcc/ada/gcc-interface/trans.c
parent517d07c980163ac34d7bf41e3e8d8dbaa38843df (diff)
downloadgcc-7194767cdf77212e8c736f41b426e3f636f52ca3.zip
gcc-7194767cdf77212e8c736f41b426e3f636f52ca3.tar.gz
gcc-7194767cdf77212e8c736f41b426e3f636f52ca3.tar.bz2
gigi.h (gnat_stabilize_reference): Adjust prototype.
* gcc-interface/gigi.h (gnat_stabilize_reference): Adjust prototype. * gcc-interface/decl.c (gnat_to_gnu_entity): Do not rely on const_flag to detect constant renamings. Be prepared for specific pattern of renamed object based on function calls. Create a constant object for the renaming of a NULL_EXPR or of a CONSTRUCTOR. Adjust calls to gnat_stabilize_reference and tidy up. Remove redundant tests. (elaborate_expression_1): Remove obsolete test and tidy up. * gcc-interface/trans.c (Call_to_gnu): Do not stabilize In/Out or Out parameters passed by reference. (gnat_to_gnu) <N_Selected_Component>: Remove redundant protection again side-effects. Use gnat_protect_expr instead of gnat_stabilize_reference for general protection against side-effects. * gcc-interface/utils2.c (gnat_stable_expr_p): New predicate. (gnat_save_expr): Invoke it. (gnat_protect_expr): Likewise. (gnat_stabilize_reference_1): Likewise. Remove useless propagation of TREE_THIS_NOTRAP. (gnat_stabilize_reference): Remove parameter and adjust throughout. Delete ADDR_EXDR, COMPOUND_EXPR and CONSTRUCTOR cases. Restrict CALL_EXPR case to atomic loads and tweak ERROR_MARK case. From-SVN: r223708
Diffstat (limited to 'gcc/ada/gcc-interface/trans.c')
-rw-r--r--gcc/ada/gcc-interface/trans.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 2cb8304..a506c63 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -4241,11 +4241,11 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target,
/* If it's possible we may need to use this expression twice, make sure
that any side-effects are handled via SAVE_EXPRs; likewise if we need
- to force side-effects before the call.
- ??? This is more conservative than we need since we don't need to do
- this for pass-by-ref with no conversion. */
- if (Ekind (gnat_formal) != E_In_Parameter)
- gnu_name = gnat_stabilize_reference (gnu_name, true, NULL);
+ to force side-effects before the call. */
+ if (Ekind (gnat_formal) != E_In_Parameter
+ && !is_by_ref_formal_parm
+ && TREE_CODE (gnu_name) != NULL_EXPR)
+ gnu_name = gnat_stabilize_reference (gnu_name, true);
/* If we are passing a non-addressable parameter by reference, pass the
address of a copy. In the Out or In Out case, set up to copy back
@@ -6099,14 +6099,6 @@ gnat_to_gnu (Node_Id gnat_node)
{
gnu_field = gnat_to_gnu_field_decl (gnat_field);
- /* If there are discriminants, the prefix might be evaluated more
- than once, which is a problem if it has side-effects. */
- if (Has_Discriminants (Is_Access_Type (Etype (Prefix (gnat_node)))
- ? Designated_Type (Etype
- (Prefix (gnat_node)))
- : Etype (Prefix (gnat_node))))
- gnu_prefix = gnat_stabilize_reference (gnu_prefix, false, NULL);
-
gnu_result
= build_component_ref (gnu_prefix, NULL_TREE, gnu_field,
(Nkind (Parent (gnat_node))
@@ -7313,7 +7305,6 @@ gnat_to_gnu (Node_Id gnat_node)
gets inserted there as well. This ensures that the type elaboration
code is issued past the actions computing values on which it might
depend. */
-
start_stmt_group ();
add_stmt_list (Actions (gnat_node));
gnu_expr = gnat_to_gnu (Expression (gnat_node));
@@ -7498,7 +7489,7 @@ gnat_to_gnu (Node_Id gnat_node)
&& TYPE_IS_PADDING_P (TREE_TYPE (gnu_result)))
&& (TREE_CODE (gnu_result_type) == UNCONSTRAINED_ARRAY_TYPE
|| CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_result_type))))
- gnu_result = gnat_stabilize_reference (gnu_result, false, NULL);
+ gnu_result = gnat_protect_expr (gnu_result);
/* Now convert the result to the result type, unless we are in one of the
following cases: