blob: b0ddc7b543cb7f1b85429617f2835b4bd2d6d0db (
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 }
extern "C" int printf(const char *, ...);
void *vp;
int fail = 0;
class Foo {
public:
virtual void setName() {
printf("Foo at %x\n", this);
if (vp != (void*)this)
fail = 1;
}
};
class Bar : public Foo {
public:
virtual void init(int argc, char **argv) {
printf("Bar's Foo at %x\n", (Foo*)this);
vp = (void*)(Foo*)this;
setName();
}
};
class Barf : virtual public Bar {
public:
virtual void init(int argc, char **argv) { Bar::init(argc, argv); }
};
class Baz : virtual public Bar, virtual public Barf {
public:
virtual void init(int argc, char **argv) { Barf::init(argc, argv); }
};
Bar *theBar = new Baz();
int main(int argc, char **argv) {
theBar->init(argc, argv);
return fail;
}
|