1 // RUN: %clang_cc1 -fsyntax-only -Wself-move -std=c++11 -verify %s
3 // definitions for std::move
6 template <class T
> struct remove_reference
{ typedef T type
; };
7 template <class T
> struct remove_reference
<T
&> { typedef T type
; };
8 template <class T
> struct remove_reference
<T
&&> { typedef T type
; };
10 template <class T
> typename remove_reference
<T
>::type
&&move(T
&&t
);
16 x
= std::move(x
); // expected-warning{{explicitly moving}}
17 (x
) = std::move(x
); // expected-warning{{explicitly moving}}
19 x
= static_cast<int&&>(x
); // expected-warning{{explicitly moving}}
20 (x
) = static_cast<int&&>(x
); // expected-warning{{explicitly moving}}
23 x
= move(x
); // expected-warning{{explicitly moving}} \
24 expected
-warning
{{unqualified call to
'std::move}}
28 void global_int_test() {
29 global = std::move(global); // expected-warning{{explicitly moving}}
30 (global) = std::move(global); // expected-warning{{explicitly moving}}
32 global = static_cast<int&&>(global); // expected-warning{{explicitly moving}}
33 (global) = static_cast<int&&>(global); // expected-warning{{explicitly moving}}
36 global = move(global); // expected-warning{{explicitly moving}} \
37 expected-warning {{unqualified call to 'std::move
}}
42 field_test(field_test
&& other
) {
43 x
= std::move(x
); // expected-warning{{explicitly moving}}
44 x
= static_cast<int&&>(x
); // expected-warning{{explicitly moving}}
45 x
= std::move(other
.x
);
46 x
= static_cast<int&&>(other
.x
);
47 other
.x
= std::move(x
);
48 other
.x
= static_cast<int&&>(x
);
49 other
.x
= std::move(other
.x
); // expected-warning{{explicitly moving}}
50 other
.x
= static_cast<int&&>(other
.x
); // expected-warning{{explicitly moving}}
52 void withSuggest(int x
) {
53 x
= static_cast<int&&>(x
); // expected-warning{{explicitly moving variable of type 'int' to itself; did you mean to move to member 'x'?}}
54 x
= std::move(x
); // expected-warning{{explicitly moving variable of type 'int' to itself; did you mean to move to member 'x'?}}
60 struct C
{ C() {}; ~C() {} };
63 a
= std::move(a
); // expected-warning{{explicitly moving}}
64 a
= static_cast<A
&&>(a
); // expected-warning{{explicitly moving}}
67 b
= std::move(b
); // expected-warning{{explicitly moving}}
68 b
= static_cast<B
&&>(b
); // expected-warning{{explicitly moving}}
69 b
.a
= std::move(b
.a
); // expected-warning{{explicitly moving}}
70 b
.a
= static_cast<A
&&>(b
.a
); // expected-warning{{explicitly moving}}
73 c
= std::move(c
); // expected-warning{{explicitly moving}}
74 c
= static_cast<C
&&>(c
); // expected-warning{{explicitly moving}}