2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / rtti4.C
blobb9cb672928619b4747bee3f002484d7762c021ee
1 // { dg-do run  }
2 // { dg-options "-frtti -w" }
3 // test of rtti of single inheritance and multiple inheritance with 
4 // virtual inheritance
6 #include <typeinfo>
8 extern "C" {
9   int printf(const char *, ...);
10   void exit(int);
13 class X {
14  public:
15   int xi;
16   virtual int f() {};
19 class Y : public virtual X {
20   short ys;
23 class Z : public virtual Y {
24   int zi;
27 Z z;
28 Y y;
29 Y *yp = &z;
30 X *xp = &z;
31 Z *zp = &z;
33 class A {
34 public:
35   int Ai;
36   virtual int a() {};
39 class B {
40 public:
41   int Bi;
42   virtual int g() {};
45 class D : public virtual A, private B {
46   int Di;
49 class E : public virtual D, public B {
50   int Ei;
53 class F : public E, public virtual D {
54   int Fi;
57 D d;
58 A *ap = &d;
59 B *bp = (B *)&d;
60 F f;
61 A *aap = &f;
62 D *dp = &f;
63 B *bbp = (B *)dp;
65 void *vp = zp;
67 void error  (int i)
69   exit(i);
72 int main ()
74   if (typeid(z) != typeid(Z)) error(1);
75   if (typeid(*yp) != typeid(Z)) error(2);
76   if (typeid(*yp) != typeid(*zp)) error(3);
77   if (typeid(xp) == typeid(yp)) error(4);
79   xp = (X *)&y;
80   if (typeid(*xp) == typeid(*yp)) error(5);
81   if (typeid(*xp) != typeid(Y)) error(6);
82   
83   if (typeid(*ap) != typeid(*bp)) error (31);
84   if (typeid(*ap) != typeid(D)) error(32);
85   if (typeid(*aap) != typeid(*bbp)) error(33);
86   if (typeid(*dp) != typeid(*aap)) error(34);