John McCall | 018591f | 2011-03-02 02:04:40 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -verify %s |
Douglas Gregor | c05babe | 2010-07-01 14:21:35 +0000 | [diff] [blame] | 2 | struct A { }; |
| 3 | struct B { }; |
Douglas Gregor | b87786f | 2010-07-01 17:48:08 +0000 | [diff] [blame] | 4 | struct C { }; |
Douglas Gregor | c05babe | 2010-07-01 14:21:35 +0000 | [diff] [blame] | 5 | |
Douglas Gregor | b87786f | 2010-07-01 17:48:08 +0000 | [diff] [blame] | 6 | // Destructor |
Douglas Gregor | c05babe | 2010-07-01 14:21:35 +0000 | [diff] [blame] | 7 | struct X0 { |
| 8 | virtual ~X0() throw(A); // expected-note{{overridden virtual function is here}} |
| 9 | }; |
| 10 | struct X1 { |
| 11 | virtual ~X1() throw(B); // expected-note{{overridden virtual function is here}} |
| 12 | }; |
| 13 | struct X2 : public X0, public X1 { }; // expected-error 2{{exception specification of overriding function is more lax than base version}} |
| 14 | |
Douglas Gregor | b87786f | 2010-07-01 17:48:08 +0000 | [diff] [blame] | 15 | // Copy-assignment operator. |
| 16 | struct CA0 { |
| 17 | CA0 &operator=(const CA0&) throw(A); |
| 18 | }; |
| 19 | struct CA1 { |
| 20 | CA1 &operator=(const CA1&) throw(B); |
| 21 | }; |
| 22 | struct CA2 : CA0, CA1 { }; |
| 23 | |
| 24 | void test_CA() { |
| 25 | CA2 &(CA2::*captr1)(const CA2&) throw(A, B) = &CA2::operator=; |
| 26 | CA2 &(CA2::*captr2)(const CA2&) throw(A, B, C) = &CA2::operator=; |
| 27 | CA2 &(CA2::*captr3)(const CA2&) throw(A) = &CA2::operator=; // expected-error{{target exception specification is not superset of source}} |
| 28 | CA2 &(CA2::*captr4)(const CA2&) throw(B) = &CA2::operator=; // expected-error{{target exception specification is not superset of source}} |
| 29 | } |