| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // This test should pass in C++03 with Clang extensions because Clang does |
| 10 | // not implicitly delete the copy constructor when move constructors are |
| 11 | // defaulted using extensions. |
| 12 | |
| 13 | // XFAIL: c++03 |
| 14 | |
| 15 | // test move |
| 16 | |
| 17 | #include <utility> |
| 18 | #include <cassert> |
| 19 | |
| 20 | struct move_only { |
| 21 | move_only() {} |
| 22 | move_only(move_only&&) = default; |
| 23 | move_only& operator=(move_only&&) = default; |
| 24 | }; |
| 25 | |
| 26 | move_only source() {return move_only();} |
| 27 | const move_only csource() {return move_only();} |
| 28 | |
| 29 | void test(move_only) {} |
| 30 | |
| 31 | int main(int, char**) |
| 32 | { |
| 33 | const move_only ca = move_only(); |
| 34 | // expected-error@+1 {{call to implicitly-deleted copy constructor of 'move_only'}} |
| 35 | test(std::move(ca)); |
| 36 | |
| 37 | return 0; |
| 38 | } |
| 39 | |