OSDN Git Service

Revert "Fix PR c++/44188"
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.eh / catch12.C
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
12 struct A {};
13 struct B : private virtual A {};
14 struct C : virtual A {};
15 struct D : private virtual A {};
16 struct E : public B, public C, public D {};
17
18 extern "C" void abort ();
19
20 void fne (E *e)
21 {
22   throw e;
23 }
24
25 void check(E *e)
26 {
27   int caught;
28   
29   caught = 0;
30   try { fne(e); }
31   catch(A *p) { caught = 1; if (p != e) abort();}
32   catch(...) { abort(); }
33   if (!caught) abort();
34
35   caught = 0;
36   try { fne(e); }
37   catch(B *p) { caught = 1; if (p != e) abort();}
38   catch(...) { abort (); }
39   if (!caught) abort();
40
41   caught = 0;
42   try { fne(e); }
43   catch(C *p) { caught = 1; if (p != e) abort();}
44   catch(...) { abort(); }
45   if (!caught) abort();
46
47   caught = 0;
48   try { fne(e); }
49   catch(D *p) { caught = 1; if (p != e) abort ();}
50   catch(...) { abort (); }
51   if (!caught) abort();
52
53   return;
54 }
55
56 int main ()
57 {
58   E e;
59   
60   check (&e);
61   check ((E *)0);
62
63   return 0;
64 }