blob: 23778c1871132522bdc0e5e00598ab90b7896d21 [file] [log] [blame]
Richard Trieu17ddb822015-01-10 06:04:18 +00001// RUN: %clang_cc1 -fsyntax-only -Wself-move -std=c++11 -verify %s
2
3// definitions for std::move
4namespace std {
5inline namespace foo {
6template <class T> struct remove_reference { typedef T type; };
7template <class T> struct remove_reference<T&> { typedef T type; };
8template <class T> struct remove_reference<T&&> { typedef T type; };
9
10template <class T> typename remove_reference<T>::type &&move(T &&t);
11}
12}
13
14void int_test() {
15 int x = 5;
16 x = std::move(x); // expected-warning{{explicitly moving}}
17 (x) = std::move(x); // expected-warning{{explicitly moving}}
18
19 using std::move;
20 x = move(x); // expected-warning{{explicitly moving}}
21}
22
23int global;
24void global_int_test() {
25 global = std::move(global); // expected-warning{{explicitly moving}}
26 (global) = std::move(global); // expected-warning{{explicitly moving}}
27
28 using std::move;
29 global = move(global); // expected-warning{{explicitly moving}}
30}
31
32class field_test {
33 int x;
34 field_test(field_test&& other) {
35 x = std::move(x); // expected-warning{{explicitly moving}}
36 x = std::move(other.x);
37 other.x = std::move(x);
38 other.x = std::move(other.x); // expected-warning{{explicitly moving}}
39 }
40};
Richard Trieu36d0b2b2015-01-13 02:32:02 +000041
42struct A {};
43struct B { A a; };
44struct C { C() {}; ~C() {} };
45void struct_test() {
46 A a;
47 a = std::move(a); // expected-warning{{explicitly moving}}
48
49 B b;
50 b = std::move(b); // expected-warning{{explicitly moving}}
51 b.a = std::move(b.a); // expected-warning{{explicitly moving}}
52
53 C c;
54 c = std::move(c); // expected-warning{{explicitly moving}}
55}