Skip to content

Commit

Permalink
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Apply the
Browse files Browse the repository at this point in the history
	promotion to static memory earlier in the processing.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251929 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
ebotcazou committed Sep 9, 2017
1 parent 626266f commit f6fc680
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
5 changes: 5 additions & 0 deletions gcc/ada/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2017-09-09 Eric Botcazou <[email protected]>

* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Apply the
promotion to static memory earlier in the processing.

2017-09-09 Eric Botcazou <[email protected]>

* gcc-interface/decl.c (gnat_to_gnu_entity): Only set the TYPE_ALIGN_OK
Expand Down
25 changes: 13 additions & 12 deletions gcc/ada/gcc-interface/decl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,19 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
gnu_size = NULL_TREE;
}

/* If this is an aggregate constant initialized to a constant, force it
to be statically allocated. This saves an initialization copy. */
if (!static_flag
&& const_flag
&& gnu_expr
&& TREE_CONSTANT (gnu_expr)
&& AGGREGATE_TYPE_P (gnu_type)
&& tree_fits_uhwi_p (TYPE_SIZE_UNIT (gnu_type))
&& !(TYPE_IS_PADDING_P (gnu_type)
&& !tree_fits_uhwi_p (TYPE_SIZE_UNIT
(TREE_TYPE (TYPE_FIELDS (gnu_type))))))
static_flag = true;

/* If this is an aliased object with an unconstrained array nominal
subtype, we make its type a thin reference, i.e. the reference
counterpart of a thin pointer, so it points to the array part.
Expand Down Expand Up @@ -1474,18 +1487,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
&& No (Address_Clause (gnat_entity))))
gnu_ext_name = create_concat_name (gnat_entity, NULL);

/* If this is an aggregate constant initialized to a constant, force it
to be statically allocated. This saves an initialization copy. */
if (!static_flag
&& const_flag
&& gnu_expr && TREE_CONSTANT (gnu_expr)
&& AGGREGATE_TYPE_P (gnu_type)
&& tree_fits_uhwi_p (TYPE_SIZE_UNIT (gnu_type))
&& !(TYPE_IS_PADDING_P (gnu_type)
&& !tree_fits_uhwi_p (TYPE_SIZE_UNIT
(TREE_TYPE (TYPE_FIELDS (gnu_type))))))
static_flag = true;

/* Deal with a pragma Linker_Section on a constant or variable. */
if ((kind == E_Constant || kind == E_Variable)
&& Present (Linker_Section_Pragma (gnat_entity)))
Expand Down

0 comments on commit f6fc680

Please sign in to comment.