1 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
2 // Contributed by Nathan Sidwell 6 Jun 1999 <nathan@acm.org>
4 // We cannot catch an ambiguous base class.
5 // -- public, << private, == virtual
10 // Special g++ Options: -w
12 struct A { int m; virtual ~A(){}};
13 struct B : A { int m; };
14 struct C : private A { int m; };
15 struct D : B, C { int m; };
17 void fna(A *obj) { throw obj; }
18 void fnb(B *obj) { throw obj; }
19 void fnc(C *obj) { throw obj; }
20 void fnd(D *obj) { throw obj; }
22 extern "C" void abort();
28 // try with whole object
31 catch(A *p) { abort(); } // A is ambiguous
32 catch(D *p) { caught = 1; if (p != d) abort();}
33 catch(...) { abort(); }
38 catch(A *p) { abort(); } // A is ambiguous
39 catch(B *p) { caught = 1; if (p != d) abort();}
40 catch(...) { abort(); }
45 catch(A *p) { abort(); } // A is ambiguous
46 catch(C *p) { caught = 1; if (p != d) abort();}
47 catch(...) { abort(); }
50 // try with an A object
53 catch(B *p) { abort(); } // throw type is static type
54 catch(A *p) { caught = 1; if (p != (B *)d) abort();}
55 catch(...) { abort(); }
59 try { fna((A *)(C *)d); }
60 catch(C *p) { abort(); } // throw type is static type
61 catch(A *p) { caught = 1; if (p != (A *)(C *)d) abort();}
62 catch(...) { abort(); }
68 catch(A *p) { caught = 1; if (p != (B *)d) abort();}
69 catch(...) { abort(); }
74 catch(B *p) { caught = 1; if (p != d) abort();}
75 catch(...) { abort(); }
80 catch(C *p) { abort(); }
81 catch(D *p) { abort(); }
82 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