3 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 6 Jun 1999 <nathan@acm.org>
6 // We cannot catch an ambiguous base class.
7 // -- public, << private, == virtual
14 struct B : A { int m; };
15 struct C : private A { int m; };
16 struct D : B, C { int m; };
18 void fna(A *obj) { throw obj; }
19 void fnb(B *obj) { throw obj; }
20 void fnc(C *obj) { throw obj; }
21 void fnd(D *obj) { throw obj; }
23 extern "C" void abort();
29 // try with whole object
32 catch(A *p) { abort(); } // A is ambiguous
33 catch(D *p) { caught = 1; if (p != d) abort();}
34 catch(...) { abort(); }
39 catch(A *p) { abort(); } // A is ambiguous
40 catch(B *p) { caught = 1; if (p != d) abort();}
41 catch(...) { abort(); }
46 catch(A *p) { abort(); } // A is ambiguous
47 catch(C *p) { caught = 1; if (p != d) abort();}
48 catch(...) { abort(); }
51 // try with an A object
54 catch(B *p) { abort(); } // throw type is static type
55 catch(A *p) { caught = 1; if (p != (B *)d) abort();}
56 catch(...) { abort(); }
60 try { fna((A *)(C *)d); }
61 catch(C *p) { abort(); } // throw type is static type
62 catch(A *p) { caught = 1; if (p != (A *)(C *)d) abort();}
63 catch(...) { abort(); }
69 catch(A *p) { caught = 1; if (p != (B *)d) abort();}
70 catch(...) { abort(); }
75 catch(B *p) { caught = 1; if (p != d) abort();}
76 catch(...) { abort(); }
81 catch(C *p) { abort(); }
82 catch(D *p) { abort(); }
83 catch(...) { caught =1; }
88 catch(A *p) { abort();}
89 catch(C *p) { caught = 1; if (p != d) abort();}
90 catch(...) { abort(); }
95 catch(B *p) { abort(); }
96 catch(D *p) { abort(); }
97 catch(...) { caught =1; }
106 check (&d); // try with an object
107 check ((D *)0); // try with no object