diff options
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/abi/bitfield3.C | 20 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/i386-bitfield1.c | 53 |
3 files changed, 69 insertions, 10 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 63175ca..2438925 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2002-08-07 Jakub Jelinek <jakub@redhat.com> + Richard Henderson <rth@redhat.com> + + * gcc.dg/i386-bitfield1.c: New test. + * g++.dg/abi/bitfield3.C: Update. + 2002-08-07 Neil Booth <neil@daikokuya.co.uk> * objc.dg/const-str-2.m: Update. diff --git a/gcc/testsuite/g++.dg/abi/bitfield3.C b/gcc/testsuite/g++.dg/abi/bitfield3.C index 1e59935..da7b92f 100644 --- a/gcc/testsuite/g++.dg/abi/bitfield3.C +++ b/gcc/testsuite/g++.dg/abi/bitfield3.C @@ -56,25 +56,25 @@ int main (void) return 4; if (__alignof__ (b.e) != 4) return 5; - if (&c.i - &c.g != 16) + if (&c.i - &c.g != 12) return 6; - if (sizeof (c) != 24) + if (sizeof (c) != 16) return 7; - if (sizeof (c4) != 4 * 24) + if (sizeof (c4) != 4 * 16) return 8; - if (sizeof (d) != 2 * 8 + 24) + if (sizeof (d) != 2 * 4 + 16) return 9; - if (__alignof__ (d.k) != 8) + if (__alignof__ (d.k) != 4) return 10; - if (&e.o - &e.m != 28) + if (&e.o - &e.m != 24) return 11; - if (sizeof (e) != 32) + if (sizeof (e) != 28) return 12; - if (sizeof (e4) != 4 * 32) + if (sizeof (e4) != 4 * 28) return 13; - if (sizeof (f) != 2 * 8 + 32) + if (sizeof (f) != 2 * 4 + 28) return 14; - if (__alignof__ (f.q) != 8) + if (__alignof__ (f.q) != 4) return 15; return 0; } diff --git a/gcc/testsuite/gcc.dg/i386-bitfield1.c b/gcc/testsuite/gcc.dg/i386-bitfield1.c new file mode 100644 index 0000000..8045a67 --- /dev/null +++ b/gcc/testsuite/gcc.dg/i386-bitfield1.c @@ -0,0 +1,53 @@ +// Test for bitfield alignment in structs on IA-32 +// { dg-do run { target i?86-*-* } } +// { dg-options "-O2" } + +extern void abort (void); +extern void exit (int); + +struct A +{ + char a; + long long b : 61; + char c; +} a, a4[4]; + +struct B +{ + char d; + struct A e; + char f; +} b; + +struct C +{ + char g; + union U + { + char u1; + long long u2; + long long u3 : 64; + } h; + char i; +} c; + +int main (void) +{ + if (&a.c - &a.a != 12) + abort (); + if (sizeof (a) != 16) + abort (); + if (sizeof (a4) != 4 * 16) + abort (); + if (sizeof (b) != 2 * 4 + 16) + abort (); + if (__alignof__ (b.e) != 4) + abort (); + if (&c.i - &c.g != 12) + abort (); + if (sizeof (c) != 16) + abort (); + if (__alignof__ (c.h) != 4) + abort (); + exit (0); +} |