blob: b03675fbfb07341293c6fad1d670c858bd4236a8 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// { dg-do run }
// prms-id: 5571
int e = 0;
void *vp = 0;
class ParentOne {
public:
ParentOne() {}
#ifdef MAKE_WORK
virtual ~ParentOne() {}
#endif
private:
char SomeData[101];
};
class ParentTwo {
public:
ParentTwo() {}
virtual ~ParentTwo() {}
private:
int MoreData[12];
virtual int foo() { return 0; }
};
struct Child : public ParentOne, public ParentTwo {
int ChildsToy;
virtual void PrintThis() = 0;
};
struct Student : public Child {
int StudentsBook;
void PrintThis() {
if (vp == 0)
vp = (void *)this;
else
{
if (vp != (void *)this)
++e;
}
}
void LocalPrintThis() {
if (vp == 0)
vp = (void *)this;
else
{
if (vp != (void *)this)
++e;
}
PrintThis();
}
void ForcedPrintThis() {
if (vp == 0)
vp = (void *)this;
else
{
if (vp != (void *)this)
++e;
}
Student::PrintThis();
}
};
int main() {
Student o;
o.LocalPrintThis();
o.ForcedPrintThis();
Child* pX = &o;
pX->PrintThis();
return e;
}
|