1// { dg-do run  }
2// Copyright (C) 2000 Free Software Foundation, Inc.
3// Contributed by Nathan Sidwell 24 May 2000 <nathan@codesourcery.com>
4
5// we should be able to catch a base a virtual, provided it is accessible by at
6// least one public path
7// -- public, << private, == virtual
8// E<<B==A
9// +--C==A
10// +<<D==A
11
12struct A {};
13struct B : virtual A {};
14struct C : virtual A {};
15struct D : virtual A {};
16struct E : private B, public C, private D {};
17
18extern "C" void abort ();
19
20void fne (E *e)
21{
22  throw e;
23}
24
25void check(E *e)
26{
27  int caught;
28
29  caught = 0;
30  try { fne(e); }
31  catch(A *p) {
32    caught = 1;
33    if (p != e) abort();
34  }
35  catch(...) { abort(); }
36  if (!caught) abort();
37
38  caught = 0;
39  try { fne(e); }
40  catch(B *p) { abort ();}
41  catch(...) { caught = 1; }
42  if (!caught) abort();
43
44  caught = 0;
45  try { fne(e); }
46  catch(C *p) {
47    caught = 1;
48    if (p != e) abort();
49  }
50  catch(...) { abort(); }
51  if (!caught) abort();
52
53  caught = 0;
54  try { fne(e); }
55  catch(D *p) { abort ();}
56  catch(...) { caught = 1; }
57  if (!caught) abort();
58
59  return;
60}
61
62int main ()
63{
64  E e;
65
66  check (&e);
67  check ((E *)0);
68
69  return 0;
70}
71