111
|
1 // { dg-do run }
|
|
2 // Ensure that virtual base upcast and downcasting works on this
|
|
3 // conversions during virtual function dispatch at ctor/dtor time
|
|
4 // when dynamic vtable fixups for deltas are needed.
|
|
5
|
|
6 int fail = 0;
|
|
7
|
|
8 struct BASE1 {
|
|
9 virtual ~BASE1 () { }
|
|
10 };
|
|
11
|
|
12 class MID;
|
|
13
|
|
14 class BASE2 {
|
|
15 public:
|
|
16 virtual MID *VFN (){ return 0; }
|
|
17 };
|
|
18
|
|
19 class MIBASE : public BASE1, public BASE2 { };
|
|
20
|
|
21 class VBB : public MIBASE {
|
|
22 public:
|
|
23 virtual long get_STATE () const = 0;
|
|
24 void print_STATE() { if (get_STATE () != 87654321) fail = 1; }
|
|
25 };
|
|
26
|
|
27 class VBD : public virtual VBB {
|
|
28 long STATE;
|
|
29 public:
|
|
30 long get_STATE() const { return STATE; }
|
|
31 VBD() { STATE = 87654321; }
|
|
32 ~VBD() { STATE = 87654321; }
|
|
33 };
|
|
34
|
|
35 class MID : public virtual VBD {
|
|
36 public:
|
|
37 MID () { print_STATE(); }
|
|
38 ~MID () { print_STATE(); }
|
|
39 virtual MID *VFN() { return this; }
|
|
40 };
|
|
41
|
|
42 class LAST : public MID {
|
|
43 public:
|
|
44 LAST () { print_STATE(); }
|
|
45 ~LAST () { print_STATE(); }
|
|
46 };
|
|
47
|
|
48 int main() {
|
|
49 MIBASE *o = new LAST;
|
|
50 MID *p = o->VFN();
|
|
51 p->print_STATE();
|
|
52 delete o;
|
|
53 return fail;
|
|
54 }
|