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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.old-deja/] [g++.other/] [rttid3.C] - Diff between revs 149 and 154

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

Rev 149 Rev 154
// { dg-do run  }
// { dg-do run  }
// { dg-options "-frtti" }
// { dg-options "-frtti" }
// test of rtti of single inheritance and multiple inheritance with
// test of rtti of single inheritance and multiple inheritance with
// virtual functions
// virtual functions
// dynamic casting
// dynamic casting
#include 
#include 
extern "C" {
extern "C" {
  int printf(const char *, ...);
  int printf(const char *, ...);
  void exit(int);
  void exit(int);
}
}
class X {
class X {
 public:
 public:
  int xi;
  int xi;
  virtual int f() {return 0;};
  virtual int f() {return 0;};
};
};
class Y : public X {
class Y : public X {
  short ys;
  short ys;
};
};
class Z : public Y {
class Z : public Y {
  int zi;
  int zi;
};
};
Z z;
Z z;
Y y;
Y y;
Y *yp = &z;
Y *yp = &z;
X *xp = &z;
X *xp = &z;
Z *zp = &z;
Z *zp = &z;
class A {
class A {
 public:
 public:
  int Ai;
  int Ai;
  virtual int a() {return 0;};
  virtual int a() {return 0;};
};
};
class B {
class B {
 public:
 public:
  int Bi;
  int Bi;
  virtual int g() {return 0;};
  virtual int g() {return 0;};
};
};
class D : public A, public B {
class D : public A, public B {
  int Di;
  int Di;
};
};
/*
/*
class E : public D, public B {
class E : public D, public B {
  int Ei;
  int Ei;
};
};
*/
*/
class E {
class E {
  int Ei;
  int Ei;
};
};
class F : public E, public D {
class F : public E, public D {
  int Fi;
  int Fi;
};
};
D d;
D d;
A *ap = &d;
A *ap = &d;
B *bp = &d;
B *bp = &d;
D *dp = &d;
D *dp = &d;
F f;
F f;
F *fp = &f;
F *fp = &f;
A *aap = &f;
A *aap = &f;
B *bbp = &f;
B *bbp = &f;
void *vp = zp;
void *vp = zp;
/*
/*
void error (int i)
void error (int i)
{
{
  printf("FAIL\n");
  printf("FAIL\n");
  exit(i);
  exit(i);
}
}
*/
*/
void error  (int i)
void error  (int i)
{
{
  exit(i);
  exit(i);
}
}
int main ()
int main ()
{
{
  vp = (void *)0;
  vp = (void *)0;
  vp = dynamic_cast (&z);
  vp = dynamic_cast (&z);
  if (vp == 0) error(11);
  if (vp == 0) error(11);
  vp = dynamic_cast (yp);
  vp = dynamic_cast (yp);
  if (vp == 0) error(11);
  if (vp == 0) error(11);
  vp = dynamic_cast (yp);
  vp = dynamic_cast (yp);
  if (vp == 0) error(12);
  if (vp == 0) error(12);
  vp = dynamic_cast (dp);
  vp = dynamic_cast (dp);
  if (vp != (void *)dp) error(21);
  if (vp != (void *)dp) error(21);
  vp = dynamic_cast (dp);
  vp = dynamic_cast (dp);
  if (vp == (void *)dp) error(21);
  if (vp == (void *)dp) error(21);
  vp = dynamic_cast (fp);
  vp = dynamic_cast (fp);
  if (vp != (void *)bbp) error(22);
  if (vp != (void *)bbp) error(22);
  vp = dynamic_cast (aap);
  vp = dynamic_cast (aap);
  if (vp != (void *)fp) error(23);
  if (vp != (void *)fp) error(23);
  vp = dynamic_cast (aap);
  vp = dynamic_cast (aap);
  if (vp != (void *)bbp) error(24);
  if (vp != (void *)bbp) error(24);
}
}
 
 

powered by: WebSVN 2.1.0

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