c++: Add new std::move test [PR67906]

As discussed in 67906, let's make sure we don't warn about a std::move
when initializing when there's a T(const T&&) ctor.

	PR c++/67906

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/Wredundant-move11.C: New test.
This commit is contained in:
Marek Polacek 2022-08-17 15:43:45 -04:00
parent 5adfb6540d
commit 177e93e952

View file

@ -0,0 +1,32 @@
// PR c++/67906
// { dg-do compile { target c++11 } }
// { dg-options "-Wall -Wextra" }
// Define std::move.
namespace std {
template<typename _Tp>
struct remove_reference
{ typedef _Tp type; };
template<typename _Tp>
struct remove_reference<_Tp&>
{ typedef _Tp type; };
template<typename _Tp>
struct remove_reference<_Tp&&>
{ typedef _Tp type; };
template<typename _Tp>
constexpr typename std::remove_reference<_Tp>::type&&
move(_Tp&& __t) noexcept
{ return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
}
struct X {
X() { }
X(const X&) { }
X(const X&&) { }
};
const X x;
const X y = std::move(x);