aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2017-09-09 12:19:25 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2017-09-09 12:19:25 +0000
commit7f46ecf6dcc9047bf659932990e55759a00978c0 (patch)
treeaae4903d9fab457d63da429eee4d4367ac948ed0 /gcc
parentea09ecc5c01685aec71da99f8949f8e403e21789 (diff)
downloadgcc-7f46ecf6dcc9047bf659932990e55759a00978c0.zip
gcc-7f46ecf6dcc9047bf659932990e55759a00978c0.tar.gz
gcc-7f46ecf6dcc9047bf659932990e55759a00978c0.tar.bz2
decl.c (gnat_to_gnu_entity): Apply the promotion to static memory earlier in the processing.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Apply the promotion to static memory earlier in the processing. From-SVN: r251929
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/decl.c25
2 files changed, 18 insertions, 12 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 6015967..2c906b9 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2017-09-09 Eric Botcazou <ebotcazou@adacore.com>
+ * 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 <ebotcazou@adacore.com>
+
* gcc-interface/decl.c (gnat_to_gnu_entity): Only set the TYPE_ALIGN_OK
and TYPE_BY_REFERENCE_P flags on types after various promotions.
* gcc-interface/trans.c (node_has_volatile_full_access) <N_Identifier>:
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index df88ce7..0798a8f 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -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.
@@ -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)))