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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.other/] [rtti4.C] - Blame information for rev 699

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do run  }
2
// { dg-options "-frtti -w" }
3
// test of rtti of single inheritance and multiple inheritance with
4
// virtual inheritance
5
 
6
#include 
7
 
8
extern "C" {
9
  int printf(const char *, ...);
10
  void exit(int);
11
}
12
 
13
class X {
14
 public:
15
  int xi;
16
  virtual int f() {};
17
};
18
 
19
class Y : public virtual X {
20
  short ys;
21
};
22
 
23
class Z : public virtual Y {
24
  int zi;
25
};
26
 
27
Z z;
28
Y y;
29
Y *yp = &z;
30
X *xp = &z;
31
Z *zp = &z;
32
 
33
class A {
34
public:
35
  int Ai;
36
  virtual int a() {};
37
};
38
 
39
class B {
40
public:
41
  int Bi;
42
  virtual int g() {};
43
};
44
 
45
class D : public virtual A, private B {
46
  int Di;
47
};
48
 
49
class E : public virtual D, public B {
50
  int Ei;
51
};
52
 
53
class F : public E, public virtual D {
54
  int Fi;
55
};
56
 
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;
64
 
65
void *vp = zp;
66
 
67
void error  (int i)
68
{
69
  exit(i);
70
}
71
 
72
int main ()
73
{
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);
78
 
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);
87
}

powered by: WebSVN 2.1.0

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