2018-03-15 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / bitfield1.c
blobecc7efe6401078b2ac9f8e502735806089e88fc6
1 // Test for bitfield alignment in structs on IA-32
2 // { dg-do run }
3 // { dg-require-effective-target ia32 }
4 // { dg-options "-O2 -mno-align-double -mno-ms-bitfields" }
6 extern void abort (void);
7 extern void exit (int);
9 struct A
11 char a;
12 long long b : 61;
13 char c;
14 } a, a4[4];
16 struct B
18 char d;
19 struct A e;
20 char f;
21 } b;
23 struct C
25 char g;
26 union U
28 char u1;
29 long long u2;
30 long long u3 : 64;
31 } h;
32 char i;
33 } c;
35 int main (void)
37 if (&a.c - &a.a != 12)
38 abort ();
39 if (sizeof (a) != 16)
40 abort ();
41 if (sizeof (a4) != 4 * 16)
42 abort ();
43 if (sizeof (b) != 2 * 4 + 16)
44 abort ();
45 if (__alignof__ (b.e) != 4)
46 abort ();
47 if (&c.i - &c.g != 12)
48 abort ();
49 if (sizeof (c) != 16)
50 abort ();
51 if (__alignof__ (c.h) != 4)
52 abort ();
53 exit (0);