OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.old-deja/] [g++.mike/] [p3708.C] - Diff between revs 305 and 338

Only display areas with differences | Details | Blame | View Log

Rev 305 Rev 338
// { dg-do run  }
// { dg-do run  }
// prms-id: 3708
// prms-id: 3708
extern "C" int printf (const char *, ...);
extern "C" int printf (const char *, ...);
extern "C" int atoi (const char *);
extern "C" int atoi (const char *);
void *ptr;
void *ptr;
class A {
class A {
public:
public:
  A() { printf ("A is constructed.\n"); }
  A() { printf ("A is constructed.\n"); }
  virtual void xx(int doit) { printf ("A is destructed.\n"); }
  virtual void xx(int doit) { printf ("A is destructed.\n"); }
};
};
class A1 {
class A1 {
public:
public:
  A1() { printf ("A1 is constructed.\n"); }
  A1() { printf ("A1 is constructed.\n"); }
  virtual void xx(int doit) { printf ("A1 is destructed.\n"); }
  virtual void xx(int doit) { printf ("A1 is destructed.\n"); }
};
};
class B : public virtual A, public A1 {
class B : public virtual A, public A1 {
public:
public:
  B() { printf ("B is constructed.\n"); }
  B() { printf ("B is constructed.\n"); }
  virtual void xx(int doit) {
  virtual void xx(int doit) {
    printf ("B is destructed.\n");
    printf ("B is destructed.\n");
    A1::xx (1);
    A1::xx (1);
    if (doit) A::xx (1);
    if (doit) A::xx (1);
  }
  }
};
};
int num;
int num;
class C : public virtual A, public B {
class C : public virtual A, public B {
public:
public:
  C() { ++num; printf ("C is constructed.\n");
  C() { ++num; printf ("C is constructed.\n");
      ptr = this;
      ptr = this;
      }
      }
  virtual void xx(int doit) {
  virtual void xx(int doit) {
    --num;
    --num;
    if (ptr != this)
    if (ptr != this)
      printf("FAIL\n%x != %x\n", ptr, this);
      printf("FAIL\n%x != %x\n", ptr, this);
    printf ("C is destructed.\n");
    printf ("C is destructed.\n");
    B::xx (0);
    B::xx (0);
    if (doit) A::xx (1);
    if (doit) A::xx (1);
  }
  }
};
};
void fooA(A *a) {
void fooA(A *a) {
  printf ("Casting to A!\n");
  printf ("Casting to A!\n");
  a->xx (1);
  a->xx (1);
}
}
void fooA1(A1 *a) {
void fooA1(A1 *a) {
  printf ("Casting to A1!\n");
  printf ("Casting to A1!\n");
  a->xx (1);
  a->xx (1);
}
}
void fooB(B *b) {
void fooB(B *b) {
  printf ("Casting to B!\n");
  printf ("Casting to B!\n");
  b->xx (1);
  b->xx (1);
}
}
void fooC(C *c) {
void fooC(C *c) {
  printf ("Casting to C!\n");
  printf ("Casting to C!\n");
  c->xx (1);
  c->xx (1);
}
}
int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
  printf ("*** Construct C object!\n");
  printf ("*** Construct C object!\n");
  C *c = new C();
  C *c = new C();
  int i = 0;
  int i = 0;
  printf ("*** Try to delete the casting pointer!\n");
  printf ("*** Try to delete the casting pointer!\n");
  switch (i)
  switch (i)
    {
    {
    case 0: fooA1(c);
    case 0: fooA1(c);
      break;
      break;
    case 1: fooA(c);
    case 1: fooA(c);
      break;
      break;
    case 2: fooB(c);
    case 2: fooB(c);
      break;
      break;
    case 3: fooC(c);
    case 3: fooC(c);
      break;
      break;
    }
    }
  return num!=0;
  return num!=0;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.