blob: c2fce17b4b08b6436bab6a888c29d050d6fddffe (
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
40
41
42
43
44
45
46
47
48
49
|
// { dg-do run }
// prms-id: 4736
class Rep {
public:
virtual int foo() { return 1; }
};
class Rep_1 : public Rep {
};
class VBaseMain {
public:
virtual int foo() { return 2; }
};
class OtherVBase {
public:
virtual int foo() { return 3; }
};
class Rep_2 : public Rep {
};
class DVBase : public VBaseMain, public Rep_2, public OtherVBase {
public:
virtual int foo() { return 4; }
};
class Main : public Rep_1, virtual public DVBase {
public:
virtual int foo() { return 5; }
};
int main() {
Main m;
if (m.foo() != 5)
return 1;
if (((Rep*)(Rep_1*)&m)->foo() != 5)
return 2;
if (((DVBase*)&m)->foo() != 5)
return 3;
if (((VBaseMain*)(DVBase*)&m)->foo() != 5)
return 4;
if (((Rep*)(Rep_2*)(DVBase*)&m)->foo() != 5)
return 5;
if (((OtherVBase*)(DVBase*)&m)->foo() != 5)
return 6;
}
|