2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.abi / vbase4.C
blob8b083947e574f7d3b73c9666535063b355e2e3d3
1 // { dg-do run  }
2 // Copyright (C) 2001 Free Software Foundation, Inc.
3 // Contributed by Nathan Sidwell 9 Jun 2001 <nathan@codesourcery.com>
5 // Bug 3089. We ICE'd in construction vtables.
7 int failed;
9 void fail (int val)
11   if (!failed)
12     failed = val;
15 struct A
17   virtual ~A();
18   A ();
19   virtual void check (void *whole, void *base);
22 A::A ()
24   check (this, this);
26 A::~A ()
28   check (this, this);
31 void A::check (void *whole, void *base)
33   if (dynamic_cast <void *> (this) != whole)
34     fail (1);
35   else if (this != base)
36     fail (2);
39 struct B
41   virtual ~B ();
42   B ();
43   virtual void check (void *whole, void *base);
46 B::B ()
48   check (this, this);
50 B::~B ()
52   check (this, this);
54 void B::check (void *whole, void *base)
56   if (dynamic_cast <void *> (this) != whole)
57     fail (3);
58   else if (this != base)
59     fail (4);
62 struct C : virtual public B, virtual public A
64   virtual ~C ();
65   C ();
66   virtual void check (void *whole, void *base);
68 C::C ()
70   check (this, this);
72 C::~C ()
74   check (this, this);
76 void C::check (void *whole, void *base)
78   if (dynamic_cast <void *> (this) != whole)
79     fail (5);
80   else if (this != base)
81     fail (6);
82   A::check (whole, static_cast <A *> (this));
83   B::check (whole, static_cast <B *> (this));
86 struct D : virtual public A
88   virtual ~D ();
89   D ();
90   virtual void check (void *whole, void *base);
92 D::D ()
94   check (this, this);
96 D::~D ()
98   check (this, this);
100 void D::check (void *whole, void *base)
102   if (dynamic_cast <void *> (this) != whole)
103     fail (5);
104   else if (this != base)
105     fail (6);
106   A::check (whole, static_cast <A *> (this));
109 struct E : virtual public C, virtual public D
111   virtual ~E ();
112   E ();
113   virtual void check (void *whole, void *base);
115 E::E ()
117   check (this, this);
119 E::~E ()
121   check (this, this);
123 void E::check (void *whole, void *base)
125   if (dynamic_cast <void *> (this) != whole)
126     fail (5);
127   else if (this != base)
128     fail (6);
129   C::check (whole, static_cast <C *> (this));
130   D::check (whole, static_cast <D *> (this));
133 struct F : virtual public E
135   virtual ~F ();
136   F ();
137   virtual void check (void *whole, void *base);
139 F::F ()
141   check (this, this);
143 F::~F ()
145   check (this, this);
147 void F::check (void *whole, void *base)
149   if (dynamic_cast <void *> (this) != whole)
150     fail (5);
151   else if (this != base)
152     fail (6);
153   E::check (whole, static_cast <F *> (this));
156 int main ()
158   A a;
159   B b;
160   C c;
161   D d;
162   E e;
163   F f;
164   
165   return failed;