decl.c (gnat_to_gnu_entity): Force constants initialized to a static constant to...
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 15 Nov 2008 12:34:00 +0000 (12:34 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 15 Nov 2008 12:34:00 +0000 (12:34 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: 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

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c

index 2e9a34aedb80e2ef740fb49f73957363e35b7cbb..776e47eeb13fbbb542bd45bce0030db877f338e8 100644 (file)
@@ -1,3 +1,10 @@
+2008-11-15  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: 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  <laurent@guerby.net>
 
        PR ada/37993
index 22ca3a51fa7e77a8d9a46007019a73d9fe3c05f8..3266e6d3542bbcaa39c92106690812fb23ef958b 100644 (file)
@@ -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,