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.
Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/67906 gcc/testsuite/ChangeLog: * g++.dg/cpp0x/Wredundant-move11.C: New test. --- .../g++.dg/cpp0x/Wredundant-move11.C | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/Wredundant-move11.C diff --git a/gcc/testsuite/g++.dg/cpp0x/Wredundant-move11.C b/gcc/testsuite/g++.dg/cpp0x/Wredundant-move11.C new file mode 100644 index 00000000000..5dfa37f1686 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wredundant-move11.C @@ -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); base-commit: 5adfb6540db95da5faf1f77fbe9ec38b4cf8eb1f -- 2.37.2