2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / eh18.C
blob02e6545e793828ff21dc253faecbb9d77494f77a
1 // { dg-do run { xfail sparc64-*-elf arm-*-pe } }
2 // { dg-options "-fexceptions" }
4 class VB {
5 public:
6   int n;
7   VB (int v) { n = v; }
8   VB (const VB& o) {
9     n = o.n;
10 //    printf("copying VB from %d to %d\n", &o, this);
11   }
14 class D : public virtual VB {
15   int j;
16 public:
17   D(int i1, int i2) : VB(i2) { j = i1; }
18   VB& vb() { return *(VB*)this; }
19   const VB& vb() const { return *(const VB*)this; }
22 class pD : private virtual VB {
23   int j;
24 public:
25   pD(int i1, int i2) : VB(i2) { j = i1; }
26   VB& vb() { return *(VB*)this; }
27   const VB& vb() const { return *(const VB*)this; }
31 int main () {
32   D d(1943, 4279);
33   pD pd(3621, 9527);
34   VB *vb = &d.vb();
35   VB *pvb = &pd.vb();
37   // A catch of a public virtual base.
38   try {
39 //    printf("Throwing D at %d (VB at %d)\n", &d, vb);
40     throw d;
41   }
42   catch (VB& vb) {
43 //    printf("Catching VB at %d\n", &vb);
44     if (vb.n != 4279)
45       return 1;
46   }
47   catch (...) {
48     return 1;
49   }
51   // A catch of a private virtual base.
52   try {
53 //    printf("Throwing D at %d (VB at %d)\n", &pd, pvb);
54     throw pd;
55   }
56   catch (VB& vb) {
57 //    printf("Catching VB at %d\n", &vb);
58     // This was a private base of the throw object, don't catch it.
59     return 1;
60   }
61   catch (...) {
62   }