Daily bump.
[gcc.git] / gcc / testsuite / g++.dg / cpp0x / Wredundant-move10.C
blob17dd807aea8937b7cc9492733665d99e9c301384
1 // PR c++/90428
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-Wredundant-move" }
5 // Define std::move.
6 namespace std {
7   template<typename _Tp>
8     struct remove_reference
9     { typedef _Tp   type; };
11   template<typename _Tp>
12     struct remove_reference<_Tp&>
13     { typedef _Tp   type; };
15   template<typename _Tp>
16     struct remove_reference<_Tp&&>
17     { typedef _Tp   type; };
19   template<typename _Tp>
20     constexpr typename std::remove_reference<_Tp>::type&&
21     move(_Tp&& __t) noexcept
22     { return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
25 struct T { T(); T(const T&); T(T&&) = delete; };
26 struct S : T { };
27 struct W { W(const W&); W(W&&) = delete; W(const W&&); };
29 T f1(T t)
31   const T& rt = t;
32   return std::move(rt); // { dg-warning "redundant move" }
35 T f2(const T& t)
37   return std::move(t); // { dg-warning "redundant move" }
40 W f3(const W& w)
42   return std::move(w);
45 T f4(const S& s)
47   return std::move(s);
50 T f5(const T t)
52   return std::move(t); // { dg-warning "redundant move" }
55 struct S1 { S1(S1 &&) = delete; S1(const S1&); };
56 struct S2: S1 {};
58 S1 f3(const S2 s)
60   return std::move(s); // { dg-warning "redundant move" }