Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.mike/thunk2.C

raw
1 // { dg-do run }
2 #include <typeinfo>
3
4 int state;
5 int fail;
6
7 class A {
8 public:
9 A() {
10 if (++state != 1)
11 fail = 1;
12 }
13 virtual int foo() {
14 if (++state != 2)
15 fail = 1;
16 return 0;
17 }
18 virtual ~A() {
19 if (++state != 3)
20 fail = 1;
21 }
22 };
23
24 A* bar() {
25 return new A;
26 }
27
28 int main() {
29 A *aptr = bar();
30 aptr->foo();
31 if (dynamic_cast <void*> (aptr) != aptr)
32 fail = 1;
33 if (typeid (*aptr) != typeid (A))
34 fail = 1;
35 delete aptr;
36 if (++state != 4)
37 fail = 1;
38 return fail;
39 }