FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / rtti4.C
blob571ed68fd9ff9627668c2ec5dbbe1fc93a07399c
1 // test of rtti of single inheritance and multiple inheritance with 
2 // virtual inheritance
3 // Special g++ Options: -frtti -w
5 #include <typeinfo>
7 extern "C" {
8   int printf(const char *, ...);
9   void exit(int);
12 class X {
13  public:
14   int xi;
15   virtual int f() {};
18 class Y : public virtual X {
19   short ys;
22 class Z : public virtual Y {
23   int zi;
26 Z z;
27 Y y;
28 Y *yp = &z;
29 X *xp = &z;
30 Z *zp = &z;
32 class A {
33 public:
34   int Ai;
35   virtual int a() {};
38 class B {
39 public:
40   int Bi;
41   virtual int g() {};
44 class D : public virtual A, private B {
45   int Di;
48 class E : public virtual D, public B {
49   int Ei;
52 class F : public E, public virtual D {
53   int Fi;
56 D d;
57 A *ap = &d;
58 B *bp = (B *)&d;
59 F f;
60 A *aap = &f;
61 D *dp = &f;
62 B *bbp = (B *)dp;
64 void *vp = zp;
66 void error  (int i)
68   exit(i);
71 int main ()
73   if (typeid(z) != typeid(Z)) error(1);
74   if (typeid(*yp) != typeid(Z)) error(2);
75   if (typeid(*yp) != typeid(*zp)) error(3);
76   if (typeid(xp) == typeid(yp)) error(4);
78   xp = (X *)&y;
79   if (typeid(*xp) == typeid(*yp)) error(5);
80   if (typeid(*xp) != typeid(Y)) error(6);
81   
82   if (typeid(*ap) != typeid(*bp)) error (31);
83   if (typeid(*ap) != typeid(D)) error(32);
84   if (typeid(*aap) != typeid(*bbp)) error(33);
85   if (typeid(*dp) != typeid(*aap)) error(34);