public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [pushed] c++: Add new std::move test [PR67906]
Date: Wed, 17 Aug 2022 15:46:16 -0400	[thread overview]
Message-ID: <20220817194616.1642511-1-polacek@redhat.com> (raw)

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


                 reply	other threads:[~2022-08-17 19:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220817194616.1642511-1-polacek@redhat.com \
    --to=polacek@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).