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