FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.abi / vbase4.C
blob116d79bec652264139a1861923e55f0ceb18db4e
1 // Copyright (C) 2001 Free Software Foundation, Inc.
2 // Contributed by Nathan Sidwell 9 Jun 2001 <nathan@codesourcery.com>
4 // Bug 3089. We ICE'd in construction vtables.
6 int failed;
8 void fail (int val)
10   if (!failed)
11     failed = val;
14 struct A
16   virtual ~A();
17   A ();
18   virtual void check (void *whole, void *base);
21 A::A ()
23   check (this, this);
25 A::~A ()
27   check (this, this);
30 void A::check (void *whole, void *base)
32   if (dynamic_cast <void *> (this) != whole)
33     fail (1);
34   else if (this != base)
35     fail (2);
38 struct B
40   virtual ~B ();
41   B ();
42   virtual void check (void *whole, void *base);
45 B::B ()
47   check (this, this);
49 B::~B ()
51   check (this, this);
53 void B::check (void *whole, void *base)
55   if (dynamic_cast <void *> (this) != whole)
56     fail (3);
57   else if (this != base)
58     fail (4);
61 struct C : virtual public B, virtual public A
63   virtual ~C ();
64   C ();
65   virtual void check (void *whole, void *base);
67 C::C ()
69   check (this, this);
71 C::~C ()
73   check (this, this);
75 void C::check (void *whole, void *base)
77   if (dynamic_cast <void *> (this) != whole)
78     fail (5);
79   else if (this != base)
80     fail (6);
81   A::check (whole, static_cast <A *> (this));
82   B::check (whole, static_cast <B *> (this));
85 struct D : virtual public A
87   virtual ~D ();
88   D ();
89   virtual void check (void *whole, void *base);
91 D::D ()
93   check (this, this);
95 D::~D ()
97   check (this, this);
99 void D::check (void *whole, void *base)
101   if (dynamic_cast <void *> (this) != whole)
102     fail (5);
103   else if (this != base)
104     fail (6);
105   A::check (whole, static_cast <A *> (this));
108 struct E : virtual public C, virtual public D
110   virtual ~E ();
111   E ();
112   virtual void check (void *whole, void *base);
114 E::E ()
116   check (this, this);
118 E::~E ()
120   check (this, this);
122 void E::check (void *whole, void *base)
124   if (dynamic_cast <void *> (this) != whole)
125     fail (5);
126   else if (this != base)
127     fail (6);
128   C::check (whole, static_cast <C *> (this));
129   D::check (whole, static_cast <D *> (this));
132 struct F : virtual public E
134   virtual ~F ();
135   F ();
136   virtual void check (void *whole, void *base);
138 F::F ()
140   check (this, this);
142 F::~F ()
144   check (this, this);
146 void F::check (void *whole, void *base)
148   if (dynamic_cast <void *> (this) != whole)
149     fail (5);
150   else if (this != base)
151     fail (6);
152   E::check (whole, static_cast <F *> (this));
155 int main ()
157   A a;
158   B b;
159   C c;
160   D d;
161   E e;
162   F f;
163   
164   return failed;