Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / gcc / testsuite / g++.dg / abi / bitfield3.C
blob864abc33b8db54e4822d64e48398cb1487df14a3
1 // Test for oversized bitfield alignment in structs on IA-32
2 // { dg-do run { target i?86-*-* } }
3 // { dg-options "-O2" }
4 // Cygwin and mingw32 default to MASK_ALIGN_DOUBLE. Override to ensure
5 // 4-byte alignment.
6 // { dg-options "-mno-align-double" { target i?86-*-cygwin* i?86-*-mingw* } }
7 // { dg-skip-if "" { i?86-*-* } { "-m64" } { "" } }
9 struct A
11   char a;
12   int b : 224;  // { dg-warning "exceeds its type" "" }
13   char c;
14 } a, a4[4];
16 struct B
18   char d;
19   A e;
20   char f;
21 } b;
23 struct C
25   char g;
26   long long h : 64;
27   char i;
28 } c, c4[4];
30 struct D
32   char j;
33   C k;
34   char l;
35 } d;
37 struct E
39   char m;
40   long long n : 160;    // { dg-warning "exceeds its type" "" }
41   char o;
42 } e, e4[4];
44 struct F
46   char p;
47   E q;
48   char r;
49 } f;
51 int main (void)
53   if (&a.c - &a.a != 32)
54     return 1;
55   if (sizeof (a) != 36)
56     return 2;
57   if (sizeof (a4) != 4 * 36)
58     return 3;
59   if (sizeof (b) != 2 * 4 + 36)
60     return 4;
61   if (__alignof__ (b.e) != 4)
62     return 5;
63   if (&c.i - &c.g != 12)
64     return 6;
65   if (sizeof (c) != 16)
66     return 7;
67   if (sizeof (c4) != 4 * 16)
68     return 8;
69   if (sizeof (d) != 2 * 4 + 16)
70     return 9;
71   if (__alignof__ (d.k) != 4)
72     return 10;
73   if (&e.o - &e.m != 24)
74     return 11;
75   if (sizeof (e) != 28)
76     return 12;
77   if (sizeof (e4) != 4 * 28)
78     return 13;
79   if (sizeof (f) != 2 * 4 + 28)
80     return 14;
81   if (__alignof__ (f.q) != 4)
82     return 15;
83   return 0;