summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.mike/p4736c.C
blob: d260b3afeb592ed5e7520f7a6b1e33838cc5d2a5 (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
// { dg-do run  }
// prms-id: 4736

int did_fail;

class Rep {
public:
  virtual ~Rep() { }
};

class Rep_1 : public Rep {
};

class VBaseMain {
public:
  virtual ~VBaseMain() { }
};

class OtherVBase {
public:
  virtual ~OtherVBase() { }
};

class Rep_2 : public Rep {
};

class DVBase : public VBaseMain, public Rep_2, public OtherVBase {
public:
  virtual ~DVBase() { }
};

class Main : public Rep_1, virtual public DVBase {
public:
  virtual ~Main() { did_fail = 0; }
};

int main() {
  Main* m;
  did_fail = 1;
  delete new Main;
  if (did_fail)
    return 1;
  did_fail = 1;
  delete (Rep*)(Rep_1*)new Main;
  if (did_fail)
    return 2;
  did_fail = 1;
  delete (DVBase*)new Main;
  if (did_fail)
    return 3;
  did_fail = 1;
  delete (VBaseMain*)(DVBase*)new Main;
  if (did_fail)
    return 4;
  did_fail = 1;
  delete (Rep*)(Rep_2*)(DVBase*)new Main;
  if (did_fail)
    return 5;
  did_fail = 1;
  delete (OtherVBase*)(DVBase*)new Main;
  if (did_fail)
    return 6;
}