1 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
2 // Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org>
4 // We cannot catch an ambiguous base class.
5 // -- public, << private, == virtual
10 // Special g++ Options: -w
13 struct B : A { int m; };
14 struct C : A { int m; };
15 struct D : virtual B, virtual 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(); }
61 catch(C *p) { abort(); } // throw type is static type
62 catch(A *p) { caught = 1; if (p != (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 != (B *)d) abort();}
76 catch(...) { abort(); }
81 catch(C *p) { abort(); }
82 catch(D *p) { abort(); }
83 catch(...) { caught =1; }
89 catch(A *p) { caught = 1; if (p != (C *)d) abort();}
90 catch(...) { abort(); }
95 catch(C *p) { caught = 1; if (p != (C *)d) abort();}
96 catch(...) { abort(); }
101 catch(B *p) { abort(); }
102 catch(D *p) { abort(); }
103 catch(...) { caught =1; }
104 if (!caught) abort();
112 check (&d); // try with an object
113 check ((D *)0); // try with no object