Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / g++.old-deja / g++.mike / p3708b.C
blob2cccc46919ab282cdcd04c9fae47691f38cb5ab6
1 // { dg-do run  }
2 // prms-id: 3708
4 extern "C" int printf (const char *, ...);
5 extern "C" void exit(int);
7 void *ptr;
9 class A {
10 public:
11   A() { printf ("A is constructed.\n"); }
12   virtual void xx(int doit) { printf ("A is destructed.\n"); }
15 class A1 {
16 public:
17   A1() { printf ("A1 is constructed.\n"); }
18   virtual void xx(int doit) { printf ("A1 is destructed.\n"); }
21 class B : public virtual A, public A1 {
22 public:
23   B() { printf ("B is constructed.\n"); }
24   virtual void xx(int doit) {
25     printf ("B is destructed.\n");
26     A1::xx (1);
27     if (doit) A::xx (1);
28   }
31 int num;
33 class C : public virtual A {
34 public:
35   C() { printf ("C is constructed.\n");
36       }
37   virtual void xx(int doit) {
38     printf ("C is destructed.\n");
39     if (doit) A::xx (1);
40   }
43 class D : public C, public B {
44 public:
45   D() { ++num; printf ("D is constructed.\n");
46       ptr = this;
47       }
48   virtual void xx(int doit) {
49     --num;
50     if (ptr != this) {
51       printf("FAIL\n%x != %x\n", ptr, this);
52       exit(1);
53     }
54     printf ("D is destructed.\n");
55     C::xx (0);
56     B::xx (0);
57   }
60 void fooA(A *a) {
61   printf ("Casting to A!\n");
62   a->xx (1);
64 void fooA1(A1 *a) {
65   printf ("Casting to A1!\n");
66   a->xx (1);
69 void fooB(B *b) {
70   printf ("Casting to B!\n");
71   b->xx (1);
74 void fooC(C *c) {
75   printf ("Casting to C!\n");
76   c->xx (1);
79 int main(int argc, char *argv[]) {
80   printf ("*** Construct D object!\n");
81   D *d = new D();
83   printf ("*** Try to delete the casting pointer!\n");
84   fooA1(d);
85   return num!=0;