]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (gnat_to_gnu_entity): Cap the alignment promotion to that of ptr_mode instead...
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 26 Sep 2008 20:11:52 +0000 (20:11 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 26 Sep 2008 20:11:52 +0000 (20:11 +0000)
* decl.c (gnat_to_gnu_entity) <object>: Cap the alignment promotion
to that of ptr_mode instead of word_mode.

From-SVN: r140711

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/specs/static_initializer3.ads
gcc/testsuite/gnat.dg/specs/static_initializer4.ads [new file with mode: 0644]

index 7ecdc2cd5dc082a4f6df216e2d053fdb9975b0dd..3aa6f4d069a62df85f55c781d07598f14615a1ca 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * decl.c (gnat_to_gnu_entity) <object>: Cap the alignment promotion
+       to that of ptr_mode instead of word_mode.
+
 2008-09-26  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR ada/5911
index d343b14499682d11fd351bc48e83918e6d403e36..b0dfc7d33e4f2e24544d6490e0e208799f030b11 100644 (file)
@@ -734,10 +734,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
            && TREE_CODE (TYPE_SIZE (gnu_type)) == INTEGER_CST)
          {
            /* No point in jumping through all the hoops needed in order
-              to support BIGGEST_ALIGNMENT if we don't really have to.  */
+              to support BIGGEST_ALIGNMENT if we don't really have to.
+              So we cap to the smallest alignment that corresponds to
+              a known efficient memory access pattern of the target.  */
            unsigned int align_cap = Is_Atomic (gnat_entity)
                                     ? BIGGEST_ALIGNMENT
-                                    : get_mode_alignment (word_mode);
+                                    : get_mode_alignment (ptr_mode);
 
            if (!host_integerp (TYPE_SIZE (gnu_type), 1)
                || compare_tree_int (TYPE_SIZE (gnu_type), align_cap) >= 0)
index 499e7c0ab7b7cb0eddffa7ab79fb0693b431c939..8169b88a56f4a82c0099e425e0b701b00ae9e1dc 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/specs/static_initializer4.ads: New test.
+       * gnat.dg/specs/static_initializer3.ads: Add missing marker.
+
 2008-09-26  Kai Tietz  <kai.tietz@onevision.com>
 
        * g++.dg/compat/struct-layout-1_x1.h: Add __SIZE_TYPE__ cast
index 42994f2e1c57660e13f8e536f3ccdf6452e2261a..2dc8be1e5beb954b54d2a5ff31a0ecb130391e9f 100644 (file)
@@ -1,3 +1,5 @@
+-- { dg-do compile }
+
 with Unchecked_Conversion;
 
 package Static_Initializer3 is
diff --git a/gcc/testsuite/gnat.dg/specs/static_initializer4.ads b/gcc/testsuite/gnat.dg/specs/static_initializer4.ads
new file mode 100644 (file)
index 0000000..a1a5e84
--- /dev/null
@@ -0,0 +1,13 @@
+-- { dg-do compile }
+
+package Static_Initializer4 is
+
+  type R is tagged record
+    b : Boolean;
+  end record;
+
+  type NR is new R with null record;
+
+  C : NR := (b => True);
+
+end Static_Initializer4;