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++.other/] [rtti2.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  }
// { dg-options "-frtti" }
// { dg-options "-frtti" }
// test of rtti of single inheritance and multiple inheritance classes
// test of rtti of single inheritance and multiple inheritance classes
#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;
};
};
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;
};
};
class B {
class B {
 public:
 public:
  int Bi;
  int Bi;
};
};
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;
F f;
F f;
A *aap = &f;
A *aap = &f;
D *dp = &f;
D *dp = &f;
B *bbp = dp;
B *bbp = dp;
void *vp = zp;
void *vp = zp;
void error  (int i)
void error  (int i)
{
{
  exit(i);
  exit(i);
}
}
int main ()
int main ()
{
{
  if (typeid(z) != typeid(Z)) error(1);
  if (typeid(z) != typeid(Z)) error(1);
  if (typeid(*yp) == typeid(Z)) error(2);
  if (typeid(*yp) == typeid(Z)) error(2);
  if (typeid(*yp) == typeid(*zp)) error(3);
  if (typeid(*yp) == typeid(*zp)) error(3);
  if (typeid(xp) == typeid(yp)) error(4);
  if (typeid(xp) == typeid(yp)) error(4);
  xp = (X *)&y;
  xp = (X *)&y;
  if (typeid(*xp) == typeid(*yp)) error(5);
  if (typeid(*xp) == typeid(*yp)) error(5);
  if (typeid(*xp) == typeid(Y)) error(6);
  if (typeid(*xp) == typeid(Y)) error(6);
  if (typeid(*ap) == typeid(*bp)) error (31);
  if (typeid(*ap) == typeid(*bp)) error (31);
  if (typeid(*ap) == typeid(D)) error(32);
  if (typeid(*ap) == typeid(D)) error(32);
  if (typeid(*aap) == typeid(*bbp)) error(33);
  if (typeid(*aap) == typeid(*bbp)) error(33);
  if (typeid(*dp) == typeid(*aap)) error(34);
  if (typeid(*dp) == typeid(*aap)) error(34);
}
}
 
 

powered by: WebSVN 2.1.0

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