aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.mike/p5571.C
blob: ec350eacb3a090730cb2529856365aab374c6482 (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
// prms-id: 5571

int err = 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)
	  ++err;
      }
  }
  void LocalPrintThis() {
    if (vp == 0)
      vp = (void *)this;
    else
      {
	if (vp != (void *)this)
	  ++err;
      }
    PrintThis();
  }
  void ForcedPrintThis() {
    if (vp == 0)
      vp = (void *)this;
    else
      {
	if (vp != (void *)this)
	  ++err;
      }
    Student::PrintThis();
  }
};

int main() {
  Student  o;
  o.LocalPrintThis();
  o.ForcedPrintThis();
  Child* pX = &o;
  pX->PrintThis();
  return err;
}