Create embedded-5_0-branch branch for development on ARM embedded cores.
[official-gcc.git] / embedded-5_0-branch / gcc / testsuite / g++.old-deja / g++.abi / empty2.C
blob65d6a459426738c8b2fa1401c3adbfd5d2d5b8bd
1 // { dg-do assemble  }
3 // Copyright (C) 2001 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 12 Apr 2001 <nathan@codesourcery.com>
6 // Check we deal with trailing empty base classes properly
8 struct A {};
9 struct B1 : A {};
10 struct B2 : A {};
11 struct B3 : A {};
12 struct B4 : A {};
13 struct B5 : A {};
14 struct B6 : A {};
15 struct B7 : A {};
16 struct B8 : A {};
18 struct C1 : B1
20   virtual void Foo () {}
22 struct C2 : B1, B2
24   virtual void Foo () {}
26 struct C3 : B1, B2, B3
28   virtual void Foo () {}
30 struct C4 : B1, B2, B3, B4
32   virtual void Foo () {}
34 struct C5 : B1, B2, B3, B4, B5
36   virtual void Foo () {}
38 struct C6 : B1, B2, B3, B4, B5, B6
40   virtual void Foo () {}
42 struct C7 : B1, B2, B3, B4, B5, B6, B7
44   virtual void Foo () {}
46 struct C8 : B1, B2, B3, B4, B5, B6, B7, B8
48   virtual void Foo () {}
51 struct D1 : virtual C1 {};
52 struct D2 : virtual C2 {};
53 struct D3 : virtual C3 {};
54 struct D4 : virtual C4 {};
55 struct D5 : virtual C5 {};
56 struct D6 : virtual C6 {};
57 struct D7 : virtual C7 {};
58 struct D8 : virtual C8 {};
60 unsigned const nearly_empty_size = sizeof (D1);
62 template <typename Cn, typename Dn> int Check (Dn const &ref)
64   if ((sizeof (Cn) <= nearly_empty_size)
65       != (static_cast <void const *> (&ref)
66           == static_cast <Cn const *> (&ref)))
67     return 1;
68   return 0;
71 template <typename Bn, typename Cn> int Check ()
73   Cn c[2];
75   if (static_cast <A *> (static_cast <B1 *> (&c[1]))
76       == static_cast <A *> (static_cast <Bn *> (&c[0])))
77     return 1;
78   return 0;
81   
82 int main ()
84 #if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
85   if (Check<B1, C1> ())
86     return 1;
87   if (Check<B2, C2> ())
88     return 2;
89   if (Check<B3, C3> ())
90     return 3;
91   if (Check<B4, C4> ())
92     return 4;
93   if (Check<B5, C5> ())
94     return 5;
95   if (Check<B6, C6> ())
96     return 6;
97   if (Check<B7, C7> ())
98     return 7;
99   if (Check<B8, C8> ())
100     return 8;
101   
102   if (Check<C1> (D1 ()))
103     return 11;
104   if (Check<C2> (D2 ()))
105     return 12;
106   if (Check<C3> (D3 ()))
107     return 13;
108   if (Check<C4> (D4 ()))
109     return 14;
110   if (Check<C5> (D5 ()))
111     return 15;
112   if (Check<C6> (D6 ()))
113     return 16;
114   if (Check<C7> (D7 ()))
115     return 17;
116   if (Check<C8> (D8 ()))
117     return 18;
118   
119   if (sizeof (C2) == nearly_empty_size)
120     return 22;
121   if (sizeof (C3) == nearly_empty_size)
122     return 23;
123   if (sizeof (C4) == nearly_empty_size)
124     return 24;
125   if (sizeof (C5) == nearly_empty_size)
126     return 25;
127   if (sizeof (C6) == nearly_empty_size)
128     return 26;
129   if (sizeof (C7) == nearly_empty_size)
130     return 27;
131   if (sizeof (C8) == nearly_empty_size)
132     return 28;
133 #endif
134   return 0;
135