Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.mike/p5571.C

raw
1 // { dg-do run }
2 // prms-id: 5571
3
4 int e = 0;
5 void *vp = 0;
6
7 class ParentOne {
8 public:
9 ParentOne() {}
10 #ifdef MAKE_WORK
11 virtual ~ParentOne() {}
12 #endif
13 private:
14 char SomeData[101];
15 };
16
17 class ParentTwo {
18 public:
19 ParentTwo() {}
20 virtual ~ParentTwo() {}
21 private:
22 int MoreData[12];
23 virtual int foo() { return 0; }
24 };
25
26 struct Child : public ParentOne, public ParentTwo {
27 int ChildsToy;
28 virtual void PrintThis() = 0;
29 };
30
31 struct Student : public Child {
32 int StudentsBook;
33 void PrintThis() {
34 if (vp == 0)
35 vp = (void *)this;
36 else
37 {
38 if (vp != (void *)this)
39 ++e;
40 }
41 }
42 void LocalPrintThis() {
43 if (vp == 0)
44 vp = (void *)this;
45 else
46 {
47 if (vp != (void *)this)
48 ++e;
49 }
50 PrintThis();
51 }
52 void ForcedPrintThis() {
53 if (vp == 0)
54 vp = (void *)this;
55 else
56 {
57 if (vp != (void *)this)
58 ++e;
59 }
60 Student::PrintThis();
61 }
62 };
63
64 int main() {
65 Student o;
66 o.LocalPrintThis();
67 o.ForcedPrintThis();
68 Child* pX = &o;
69 pX->PrintThis();
70 return e;
71 }