diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2015-05-25 14:00:28 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2015-05-25 14:00:28 +0000 |
commit | ea292448322b87fcd3f8da04467420b49f609053 (patch) | |
tree | ad069168b45b5aa8b35d5e2c20ccbc3558fcf80d /gcc/ada/gcc-interface/trans.c | |
parent | 288cbbbdacf90e3da12df2fd0cffba69f66369ac (diff) | |
download | gcc-ea292448322b87fcd3f8da04467420b49f609053.zip gcc-ea292448322b87fcd3f8da04467420b49f609053.tar.gz gcc-ea292448322b87fcd3f8da04467420b49f609053.tar.bz2 |
ada-tree.h (DECL_RENAMING_GLOBAL_P): Rename into...
* gcc-interface/ada-tree.h (DECL_RENAMING_GLOBAL_P): Rename into...
(DECL_GLOBAL_NONCONSTANT_RENAMING_P): ...this.
* gcc-interface/gigi.h (record_global_renaming_pointer): Delete.
(invalidate_global_renaming_pointers): Likewise.
(record_global_nonconstant_renaming): New.
(invalidate_global_nonconstant_renamings): Likewise.
(get_inner_constant_reference): Likewise.
(gnat_constant_reference_p): Likewise.
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Adjust to above
and register the renaming pointer only if the object is non-constant.
(elaborate_expression_1): Call get_inner_constant_reference instead
of get_inner_reference.
* gcc-interface/trans.c (fold_constant_decl_in_expr): Minor tweak.
(Identifier_to_gnu): Adjust to above and do not recheck the renamed
object before substituting it.
(Compilation_Unit_to_gnu): Adjust to above renaming. Minor tweaks.
(gnat_to_gnu) <N_Object_Renaming_Declaration>: Do not return the
result at the global level.
(N_Exception_Renaming_Declaration): Likewise.
* gcc-interface/utils.c (global_renaming_pointers): Rename into...
(global_nonconstant_renamings): ...this.
(destroy_gnat_utils): Adjust to above renaming.
(record_global_renaming_pointer): Rename into...
(record_global_nonconstant_renaming): ...this.
(invalidate_global_renaming_pointers): Rename into...
(invalidate_global_nonconstant_renamings): ...this and do not recheck
the renamed object before invalidating.
* gcc-interface/utils2.c (gnat_stabilize_reference): Minor tweak.
(get_inner_constant_reference): New public function.
(gnat_constant_reference_p): New predicate.
From-SVN: r223644
Diffstat (limited to 'gcc/ada/gcc-interface/trans.c')
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 917a9a6..03f3e30 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -1004,9 +1004,9 @@ fold_constant_decl_in_expr (tree exp) return fold (build4 (code, TREE_TYPE (exp), op0, TREE_OPERAND (exp, 1), TREE_OPERAND (exp, 2), TREE_OPERAND (exp, 3))); - case VIEW_CONVERT_EXPR: case REALPART_EXPR: case IMAGPART_EXPR: + case VIEW_CONVERT_EXPR: op0 = fold_constant_decl_in_expr (TREE_OPERAND (exp, 0)); if (op0 == TREE_OPERAND (exp, 0)) return exp; @@ -1165,15 +1165,14 @@ Identifier_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p) true, false))) gnu_result = DECL_INITIAL (gnu_result); - /* If it's a renaming pointer and, either the renamed object is constant - or we are at the right binding level, we can reference the renamed - object directly, since it is constant or has been protected against + /* If it's a renaming pointer and not a global non-constant renaming or + we are at the global level, the we can reference the renamed object + directly, since it is either constant or has been protected against multiple evaluations. */ if (TREE_CODE (gnu_result) == VAR_DECL && !DECL_LOOP_PARM_P (gnu_result) && DECL_RENAMED_OBJECT (gnu_result) - && (TREE_CONSTANT (DECL_RENAMED_OBJECT (gnu_result)) - || !DECL_RENAMING_GLOBAL_P (gnu_result) + && (!DECL_GLOBAL_NONCONSTANT_RENAMING_P (gnu_result) || global_bindings_p ())) gnu_result = DECL_RENAMED_OBJECT (gnu_result); @@ -5143,28 +5142,24 @@ Compilation_Unit_to_gnu (Node_Id gnat_node) add_stmt_list (Actions (Aux_Decls_Node (gnat_node))); finalize_from_limited_with (); - /* Save away what we've made so far and record this potential elaboration - procedure. */ - info = ggc_alloc<elab_info> (); + /* Save away what we've made so far and finish it up. */ set_current_block_context (gnu_elab_proc_decl); gnat_poplevel (); DECL_SAVED_TREE (gnu_elab_proc_decl) = end_stmt_group (); - set_end_locus_from_node (gnu_elab_proc_decl, gnat_unit); + gnu_elab_proc_stack->pop (); + /* Record this potential elaboration procedure for later processing. */ + info = ggc_alloc<elab_info> (); info->next = elab_info_list; info->elab_proc = gnu_elab_proc_decl; info->gnat_node = gnat_node; elab_info_list = info; - /* Generate elaboration code for this unit, if necessary, and say whether - we did or not. */ - gnu_elab_proc_stack->pop (); - - /* Invalidate the global renaming pointers. This is necessary because - stabilization of the renamed entities may create SAVE_EXPRs which - have been tied to a specific elaboration routine just above. */ - invalidate_global_renaming_pointers (); + /* Invalidate the global non-constant renamings. This is necessary because + stabilization of the renamed entities may create SAVE_EXPRs which have + been tied to a specific elaboration routine just above. */ + invalidate_global_nonconstant_renamings (); /* Force the processing for all nodes that remain in the queue. */ process_deferred_decl_context (true); @@ -5695,31 +5690,40 @@ gnat_to_gnu (Node_Id gnat_node) case N_Object_Renaming_Declaration: gnat_temp = Defining_Entity (gnat_node); + gnu_result = alloc_stmt_list (); /* Don't do anything if this renaming is handled by the front end or if we are just annotating types and this object has a composite or task - type, don't elaborate it. We return the result in case it has any - SAVE_EXPRs in it that need to be evaluated here. */ + type, don't elaborate it. We return the result in case it contains + any SAVE_EXPRs that need to be evaluated here, but this cannot occur + at the global level (see Renaming, case 2 in gnat_to_gnu_entity). */ if (!Is_Renaming_Of_Object (gnat_temp) && ! (type_annotate_only && (Is_Array_Type (Etype (gnat_temp)) || Is_Record_Type (Etype (gnat_temp)) || Is_Concurrent_Type (Etype (gnat_temp))))) - gnu_result - = gnat_to_gnu_entity (gnat_temp, - gnat_to_gnu (Renamed_Object (gnat_temp)), 1); - else - gnu_result = alloc_stmt_list (); + { + tree gnu_temp + = gnat_to_gnu_entity (gnat_temp, + gnat_to_gnu (Renamed_Object (gnat_temp)), 1); + if (!global_bindings_p ()) + gnu_result = gnu_temp; + } break; case N_Exception_Renaming_Declaration: gnat_temp = Defining_Entity (gnat_node); - if (Renamed_Entity (gnat_temp) != Empty) - gnu_result - = gnat_to_gnu_entity (gnat_temp, - gnat_to_gnu (Renamed_Entity (gnat_temp)), 1); - else - gnu_result = alloc_stmt_list (); + gnu_result = alloc_stmt_list (); + + /* See the above case for the rationale. */ + if (Present (Renamed_Entity (gnat_temp))) + { + tree gnu_temp + = gnat_to_gnu_entity (gnat_temp, + gnat_to_gnu (Renamed_Entity (gnat_temp)), 1); + if (!global_bindings_p ()) + gnu_result = gnu_temp; + } break; case N_Implicit_Label_Declaration: |