diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1935139e6c7..c2b39dbf280 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2017-09-09 Eric Botcazou + + * gcc-interface/decl.c (gnat_to_gnu_entity) : Apply the + promotion to static memory earlier in the processing. + 2017-09-09 Eric Botcazou * sem_util.ads (Set_Rep_Info): New inline procedure. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index cefa852f99e..76e917a6c33 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -1416,6 +1416,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. @@ -1466,18 +1479,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)))