| 1 | // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -fsyntax-only -verify %s |
| 2 | class X { |
| 3 | X(const X&); |
| 4 | |
| 5 | public: |
| 6 | X(); |
| 7 | X(X&&); |
| 8 | }; |
| 9 | |
| 10 | X return_by_move(int i, X x) { |
| 11 | X x2; |
| 12 | if (i == 0) |
| 13 | return x; |
| 14 | else if (i == 1) |
| 15 | return x2; |
| 16 | else |
| 17 | return x; |
| 18 | } |
| 19 | |
| 20 | void throw_move_only(X x) { |
| 21 | X x2; |
| 22 | throw x; |
| 23 | throw x2; |
| 24 | } |
| 25 | |
| 26 | namespace PR10142 { |
| 27 | struct X { |
| 28 | X(); |
| 29 | X(X&&); |
| 30 | X(const X&) = delete; // expected-note 2{{'X' has been explicitly marked deleted here}} |
| 31 | }; |
| 32 | |
| 33 | void f(int i) { |
| 34 | X x; |
| 35 | try { |
| 36 | X x2; |
| 37 | if (i) |
| 38 | throw x2; // okay |
| 39 | throw x; // expected-error{{call to deleted constructor of 'PR10142::X'}} |
| 40 | } catch (...) { |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | template<typename T> |
| 45 | void f2(int i) { |
| 46 | T x; |
| 47 | try { |
| 48 | T x2; |
| 49 | if (i) |
| 50 | throw x2; // okay |
| 51 | throw x; // expected-error{{call to deleted constructor of 'PR10142::X'}} |
| 52 | } catch (...) { |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | template void f2<X>(int); // expected-note{{in instantiation of function template specialization 'PR10142::f2<PR10142::X>' requested here}} |
| 57 | } |
| 58 | |