Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s |
Sean Hunt | be63122 | 2011-05-17 20:44:43 +0000 | [diff] [blame] | 2 | |
| 3 | struct non_copiable { |
| 4 | non_copiable(const non_copiable&) = delete; // expected-note {{marked deleted here}} |
| 5 | non_copiable& operator = (const non_copiable&) = delete; // expected-note {{explicitly deleted}} |
| 6 | non_copiable() = default; |
| 7 | }; |
| 8 | |
| 9 | struct non_const_copy { |
| 10 | non_const_copy(non_const_copy&) = default; // expected-note {{not viable}} |
| 11 | non_const_copy& operator = (non_const_copy&) & = default; // expected-note {{not viable}} |
| 12 | non_const_copy& operator = (non_const_copy&) && = default; // expected-note {{not viable}} |
| 13 | non_const_copy() = default; // expected-note {{not viable}} |
| 14 | }; |
| 15 | |
| 16 | void fn1 () { |
| 17 | non_copiable nc; |
| 18 | non_copiable nc2 = nc; // expected-error {{deleted constructor}} |
| 19 | nc = nc; // expected-error {{deleted operator}} |
| 20 | |
| 21 | non_const_copy ncc; |
| 22 | non_const_copy ncc2 = ncc; |
| 23 | ncc = ncc2; |
| 24 | const non_const_copy cncc; |
| 25 | non_const_copy ncc3 = cncc; // expected-error {{no matching}} |
| 26 | ncc = cncc; // expected-error {{no viable overloaded}} |
| 27 | }; |
| 28 | |
| 29 | struct non_const_derived : non_const_copy { |
| 30 | non_const_derived(const non_const_derived&) = default; // expected-error {{requires it to be non-const}} |
| 31 | non_const_derived& operator =(non_const_derived&) = default; |
| 32 | }; |
| 33 | |
| 34 | struct bad_decls { |
| 35 | bad_decls(volatile bad_decls&) = default; // expected-error {{may not be volatile}} |
| 36 | bad_decls&& operator = (bad_decls) = default; // expected-error 2{{lvalue reference}} |
| 37 | bad_decls& operator = (volatile bad_decls&) = default; // expected-error {{may not be volatile}} |
Richard Smith | 55dec86 | 2011-09-30 00:45:47 +0000 | [diff] [blame] | 38 | bad_decls& operator = (const bad_decls&) const = default; // expected-error {{may not have 'const', 'constexpr' or 'volatile' qualifiers}} |
Sean Hunt | be63122 | 2011-05-17 20:44:43 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | struct A {}; struct B {}; |
| 42 | |
| 43 | struct except_spec_a { |
| 44 | virtual ~except_spec_a() throw(A); |
| 45 | except_spec_a() throw(A); |
| 46 | }; |
| 47 | struct except_spec_b { |
| 48 | virtual ~except_spec_b() throw(B); |
| 49 | except_spec_b() throw(B); |
| 50 | }; |
| 51 | |
| 52 | struct except_spec_d_good : except_spec_a, except_spec_b { |
| 53 | ~except_spec_d_good(); |
| 54 | }; |
| 55 | except_spec_d_good::~except_spec_d_good() = default; |
| 56 | // FIXME: This should error in the virtual override check. |
| 57 | // It doesn't because we generate the implicit specification later than |
| 58 | // appropriate. |
| 59 | struct except_spec_d_bad : except_spec_a, except_spec_b { |
| 60 | ~except_spec_d_bad() = default; |
| 61 | }; |
| 62 | |
| 63 | // FIXME: This should error because the exceptions spec doesn't match. |
| 64 | struct except_spec_d_mismatch : except_spec_a, except_spec_b { |
| 65 | except_spec_d_mismatch() throw(A) = default; |
| 66 | }; |
| 67 | struct except_spec_d_match : except_spec_a, except_spec_b { |
| 68 | except_spec_d_match() throw(A, B) = default; |
| 69 | }; |