* [pushed] c++: Add new std::move test [PR67906]
@ 2022-08-17 19:46 Marek Polacek
0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2022-08-17 19:46 UTC (permalink / raw)
To: GCC Patches
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-17 19:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-17 19:46 [pushed] c++: Add new std::move test [PR67906] Marek Polacek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).