xref: /openbsd-src/gnu/usr.bin/gcc/gcc/testsuite/g++.old-deja/g++.abi/empty.C (revision c87b03e512fc05ed6e0222f6fb0ae86264b1d05b)
1 // Special g++ Options: -w
2 // Origin: Mark Mitchell <mark@codesourcery.com>
3 
4 #if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
5 
6 struct S0
7 {
8 };
9 
10 struct S1 : public S0
11 {
12 };
13 
14 struct S2 : public S1
15 {
16   char c;
17 };
18 
19 // In S3, the S1 instance is allocated first at offset zero.  The S2
20 // instance has to be allocated at a subsequent offset; it's first
21 // part is also an S1.
22 
23 struct S3 : public S1, public S2
24 {
25 };
26 
27 struct S4
28 {
29   int i;
30 };
31 
32 // In S4, in contrast to S3, S2 is allocated first, and S1 can be
33 // allocated on top of S4.
34 
35 struct S5 : public S2, public S1, public S4
36 {
37 };
38 
39 // The T classes are by-hand layouts that should be equivalent to the
40 // S classes.
41 
42 struct T3
43 {
44   S1 s1;
45   S2 s2;
46 };
47 
48 struct T5
49 {
50   S2 s2;
51   S4 s4;
52 };
53 
main()54 int main ()
55 {
56   if (sizeof (S3) != sizeof (T3))
57     return 1;
58   else if (sizeof (S5) != sizeof (T5))
59     return 2;
60 }
61 
62 #else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */
63 
main()64 int main ()
65 {
66 }
67 
68 #endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */
69