From: Eric Botcazou Date: Sat, 15 Nov 2008 12:34:00 +0000 (+0000) Subject: decl.c (gnat_to_gnu_entity): Force constants initialized to a static constant to... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a5b8aacdd2b91ccfa37825d358141bad4cba1d11;p=gcc.git decl.c (gnat_to_gnu_entity): Force constants initialized to a static constant to be statically allocated... * gcc-interface/decl.c (gnat_to_gnu_entity) : Force constants initialized to a static constant to be statically allocated even if they are of a padding type, provided the original type also has constant size. From-SVN: r141883 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 2e9a34aedb8..776e47eeb13 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2008-11-15 Eric Botcazou + + * gcc-interface/decl.c (gnat_to_gnu_entity) : Force constants + initialized to a static constant to be statically allocated even if + they are of a padding type, provided the original type also has + constant size. + 2008-11-15 Laurent Guerby PR ada/37993 diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 22ca3a51fa7..3266e6d3542 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -1281,12 +1281,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* If this is constant initialized to a static constant and the object has an aggregate type, force it to be statically - allocated. */ - if (const_flag && gnu_expr && TREE_CONSTANT (gnu_expr) + allocated. This will avoid an initialization copy. */ + if (!static_p && const_flag + && gnu_expr && TREE_CONSTANT (gnu_expr) + && AGGREGATE_TYPE_P (gnu_type) && host_integerp (TYPE_SIZE_UNIT (gnu_type), 1) - && (AGGREGATE_TYPE_P (gnu_type) - && !(TREE_CODE (gnu_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_type)))) + && !(TREE_CODE (gnu_type) == RECORD_TYPE + && TYPE_IS_PADDING_P (gnu_type) + && !host_integerp (TYPE_SIZE_UNIT + (TREE_TYPE (TYPE_FIELDS (gnu_type))), 1))) static_p = true; gnu_decl = create_var_decl (gnu_entity_id, gnu_ext_name, gnu_type,