i386.c (x86_field_alignment): Apply min for all MODE_INT and MODE_CLASS_INT modes.
authorJakub Jelinek <jakub@redhat.com>
Tue, 6 Aug 2002 15:36:40 +0000 (17:36 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 6 Aug 2002 15:36:40 +0000 (17:36 +0200)
* config/i386/i386.c (x86_field_alignment): Apply min for all MODE_INT
and MODE_CLASS_INT modes.

* g++.dg/abi/bitfield3.C: New test.

From-SVN: r56072

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/abi/bitfield3.C [new file with mode: 0644]

index ade9711875af77882e8e146f4dd33c99f5f35ca0..f609be35ccc281a80c2a11e2a4e3bb9ebf01bb62 100644 (file)
@@ -1,3 +1,9 @@
+2002-08-06  Jakub Jelinek  <jakub@redhat.com>
+
+       * config/i386/i386.c (x86_field_alignment): Don't check
+       TARGET_ALIGN_DOUBLE for the second time.
+       Apply min for all MODE_INT and MODE_CLASS_INT modes.
+
 2002-08-06  Jakub Jelinek  <jakub@redhat.com>
 
        * config.gcc (*-*-linux*): Default to --enable-threads=posix if no
index f2e33c6f77b1ee876cfc095f5c997968ad92e151..ae2fe990db3086f13ddb3b27f0aa1d6fe2887b2e 100644 (file)
@@ -13822,7 +13822,9 @@ x86_field_alignment (field, computed)
     return computed;
   mode = TYPE_MODE (TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE
                    ? get_inner_array_type (field) : TREE_TYPE (field));
-  if (mode == DFmode || mode == DCmode || mode == DImode || mode == CDImode)
+  if (mode == DFmode || mode == DCmode
+      || GET_MODE_CLASS (mode) == MODE_INT
+      || GET_MODE_CLASS (mode) == MODE_COMPLEX_INT)
     return MIN (32, computed);
   return computed;
 }
index b9de8f5aaf7988a7967373799ae18258f19ea8d1..016152af1d1387b83977a36a541c45fb48c8b92d 100644 (file)
@@ -1,3 +1,7 @@
+2002-08-06  Jakub Jelinek  <jakub@redhat.com>
+
+       * g++.dg/abi/bitfield3.C: New test.
+
 2002-08-05  Nathan Sidwell  <nathan@codesourcery.com>
 
        * lib/gcov.exp: Tweak expected line formats.
diff --git a/gcc/testsuite/g++.dg/abi/bitfield3.C b/gcc/testsuite/g++.dg/abi/bitfield3.C
new file mode 100644 (file)
index 0000000..1e59935
--- /dev/null
@@ -0,0 +1,80 @@
+// Test for oversized bitfield alignment in structs on IA-32
+// { dg-do run { target i?86-*-* } }
+// { dg-options "-O2" }
+
+struct A
+{
+  char a;
+  int b : 224; // { dg-warning "exceeds its type" "" }
+  char c;
+} a, a4[4];
+
+struct B
+{
+  char d;
+  A e;
+  char f;
+} b;
+
+struct C
+{
+  char g;
+  long long h : 64;
+  char i;
+} c, c4[4];
+
+struct D
+{
+  char j;
+  C k;
+  char l;
+} d;
+
+struct E
+{
+  char m;
+  long long n : 160;   // { dg-warning "exceeds its type" "" }
+  char o;
+} e, e4[4];
+
+struct F
+{
+  char p;
+  E q;
+  char r;
+} f;
+
+int main (void)
+{
+  if (&a.c - &a.a != 32)
+    return 1;
+  if (sizeof (a) != 36)
+    return 2;
+  if (sizeof (a4) != 4 * 36)
+    return 3;
+  if (sizeof (b) != 2 * 4 + 36)
+    return 4;
+  if (__alignof__ (b.e) != 4)
+    return 5;
+  if (&c.i - &c.g != 16)
+    return 6;
+  if (sizeof (c) != 24)
+    return 7;
+  if (sizeof (c4) != 4 * 24)
+    return 8;
+  if (sizeof (d) != 2 * 8 + 24)
+    return 9;
+  if (__alignof__ (d.k) != 8)
+    return 10;
+  if (&e.o - &e.m != 28)
+    return 11;
+  if (sizeof (e) != 32)
+    return 12;
+  if (sizeof (e4) != 4 * 32)
+    return 13;
+  if (sizeof (f) != 2 * 8 + 32)
+    return 14;
+  if (__alignof__ (f.q) != 8)
+    return 15;
+  return 0;
+}