diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-13 21:40:51 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-13 21:40:51 +0000 |
commit | 442c80fd37f5728ee2e8c02ca41682f3dedeb4be (patch) | |
tree | ca4e054f37d2b08bfcf30ed0bd62cba30a72b076 /gcc/ada/decl.c | |
parent | 6493c502114a908d4b550cb5df658f6dddd7e7ef (diff) | |
download | gcc-442c80fd37f5728ee2e8c02ca41682f3dedeb4be.tar.gz |
2004-07-13 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* decl.c: (gnat_to_gnu_entity, object case): Convert initializer to
object type.
(gnat_to_gnu_entity, case E_Record_Subtype): Properly set
TYPE_STUB_DECL.
* misc.c (gnat_types_compatible_p): New function.
(LANG_HOOKS_TYPES_COMPATIBLE_P): New hook, to use it.
(LANG_HOOKS_TYPE_MAX_SIZE, gnat_type_max_size): New.
* trans.c (gigi): Move processing of main N_Compilation_Unit here.
(gnat_to_gnu, case N_Compilation_Unit): Just handle nested case here.
(add_stmt): Force walking of sizes and DECL_INITIAL for DECL_EXPR.
(mark_visited): Don't mark dummy type.
(tree_transform <N_Procedure_Call_Statement>): Unless this is an In
parameter, we must remove any LJM building from GNU_NAME.
(gnat_to_gnu, case N_String_Literal): Fill in indices in CONSTRUCTOR.
(pos_to_constructor): Use int_const_binop.
(gnat_to_gnu, case N_Identifier): Don't reference DECL_INITIAL of
PARM_DECL.
* utils.c (gnat_init_decl_processing): Don't make two "void" decls.
(gnat_pushlevel): Set TREE_USE on BLOCK node.
(gnat_install_builtins): Add __builtin_memset.
2004-07-13 Olivier Hainque <hainque@act-europe.fr>
* decl.c (gnat_to_gnu_entity <E_Variable>): If we are making a pointer
for a renaming, stabilize the initialization expression if we are at a
local level. At the local level, uses of the renaming may be performed
by a direct dereference of the initializing expression, and we don't
want possible variables there to be evaluated for every use.
* trans.c (gnat_stabilize_reference, gnat_stabilize_reference_1):
Propagate TREE_SIDE_EFFECTS and TREE_THIS_VOLATILE to avoid loosing
them on the way. Account for the fact that we may introduce side
effects in the process.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84647 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/decl.c')
-rw-r--r-- | gcc/ada/decl.c | 60 |
1 files changed, 43 insertions, 17 deletions
diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c index 5ef6ef5db9f..e719072a4fd 100644 --- a/gcc/ada/decl.c +++ b/gcc/ada/decl.c @@ -728,15 +728,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS (gnu_type))))))) gnu_expr = convert (gnu_type, gnu_expr); - /* See if this is a renaming. If this is a constant renaming, - treat it as a normal variable whose initial value is what - is being renamed. We cannot do this if the type is - unconstrained or class-wide. + /* See if this is a renaming. If this is a constant renaming, treat + it as a normal variable whose initial value is what is being + renamed. We cannot do this if the type is unconstrained or + class-wide. Otherwise, if what we are renaming is a reference, we can simply - return a stabilized version of that reference, after forcing - any SAVE_EXPRs to be evaluated. But, if this is at global level, - we can only do this if we know no SAVE_EXPRs will be made. + return a stabilized version of that reference, after forcing any + SAVE_EXPRs to be evaluated. But, if this is at global level, we + can only do this if we know no SAVE_EXPRs will be made. + Otherwise, make this into a constant pointer to the object we are to rename. */ @@ -761,8 +762,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) && !Is_Array_Type (Etype (gnat_entity))) ; - /* If this is a declaration or reference, we can just use that - declaration or reference as this entity. */ + /* If this is a declaration or reference that we can stabilize, + just use that declaration or reference as this entity unless + the latter has to be materialized. */ else if ((DECL_P (gnu_expr) || TREE_CODE_CLASS (TREE_CODE (gnu_expr)) == 'r') && ! Materialize_Entity (gnat_entity) @@ -775,12 +777,33 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) saved = 1; break; } + /* Otherwise, make this into a constant pointer to the object we + are to rename. + + Stabilize it if we are not at the global level since in this + case the renaming evaluation may directly dereference the + initial value we make here instead of the pointer we will + assign it to. We don't want variables in the expression to be + evaluated every time the renaming is used, since the value of + these variables may change in between. + + If we are at the global level and the value is not constant, + create_var_decl generates a mere elaboration assignment and + does not attach the initial expression to the declaration. + There is no possible direct initial-value dereference then. */ else { inner_const_flag = TREE_READONLY (gnu_expr); const_flag = 1; gnu_type = build_reference_type (gnu_type); gnu_expr = build_unary_op (ADDR_EXPR, gnu_type, gnu_expr); + + if (! global_bindings_p ()) + { + gnu_expr = gnat_stabilize_reference (gnu_expr, 1); + add_stmt (gnu_expr); + } + gnu_size = 0; used_by_ref = 1; } @@ -999,17 +1022,20 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) with the symbol we need to export in addition. Don't use the Interface_Name if there is an address clause (see CD30005). */ if (! Is_VMS_Exception (gnat_entity) - && - ((Present (Interface_Name (gnat_entity)) - && No (Address_Clause (gnat_entity))) - || - (Is_Public (gnat_entity) - && (! Is_Imported (gnat_entity) || Is_Exported (gnat_entity))))) + && ((Present (Interface_Name (gnat_entity)) + && No (Address_Clause (gnat_entity))) + || (Is_Public (gnat_entity) + && (! Is_Imported (gnat_entity) + || Is_Exported (gnat_entity))))) gnu_ext_name = create_concat_name (gnat_entity, 0); if (const_flag) - gnu_type = build_qualified_type (gnu_type, (TYPE_QUALS (gnu_type) - | TYPE_QUAL_CONST)); + { + gnu_type = build_qualified_type (gnu_type, (TYPE_QUALS (gnu_type) + | TYPE_QUAL_CONST)); + if (gnu_expr) + gnu_expr = convert (gnu_type, gnu_expr); + } /* If this is constant initialized to a static constant and the object has an aggregrate type, force it to be statically |