From patchwork Wed Aug 17 19:46:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 586 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp2858097pxh; Wed, 17 Aug 2022 12:47:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Wp9m9uqWwcGRqQfltNg5TF97BP/lGiazvym0EW0Y3z+ULGX5Xx1y3xHx89RpkUQiPY9Nw X-Received: by 2002:aa7:d856:0:b0:445:e147:e014 with SMTP id f22-20020aa7d856000000b00445e147e014mr3447119eds.425.1660765630574; Wed, 17 Aug 2022 12:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660765630; cv=none; d=google.com; s=arc-20160816; b=tkjGDcfPPB5Vz1nAEdXte8fDMxd0rzmfNtR8hRV0HbUU02qahYq0Ken8lPRo7HZh7C DxMxuYUJUALuxUZDNiWpFR1S3vbHAXRN8GluVSFCick8JcaaNgijrR3XoKd1naOvP4g0 Ja8rWEE+2x5EobZr+Ua54V1RMiI1RVbGe9O4ofQW+3KWVe4GMbISYnMaq178khPZ8P/X sI0uozlL0tO9RitLKA11chssKk3ueFGGcsPkXIPU1fqLY9iI8z77Bw65ZdLteijLaKSo X8pubuq/p6qwAPTgyXK4zDPHjWroP4i30CELn1da8DqGOxHYRfN9cg5TAlRdTb4M2sLi /i5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=1n55pVNmuOGWVDcROI2zL/Wp9eLm2EHkPGJp9Ic7w8w=; b=u2nS+n0XsqNM7rh5VTFhZmCj9JwLnk1woSPj3HbjWEOCbfwbsUazZyHypsPgIlI1+h dEQ/EA8fzLfsQgRZAqCcDg8/0PMr/TDDsQ5iBdYtMQPuRmII1JlfPLfwxN0AQ5mpb1bk c6ruDxhlLhyZxbYsvd9hM7gZDdy6/VT4aI+bfAgXBjdmGWVOzHA6Kx2B816T6nowPuNU uXnsFQyyqPxEjnHYRP6HT+pbK/u2l4cIQmlHR6LO5B/cNqEcUT33HSH5Y7fhNpq/Z3zW QyuYIZIyEXtEgECg9/jeRWPx+SQ179wUyL8xhayXdsugUQsGYvkeGd0BWoWuNm278Nn7 I30g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=h2UykquJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qa6-20020a170907868600b007306b2bfa66si14162083ejc.851.2022.08.17.12.47.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 12:47:10 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=h2UykquJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 178E43858C83 for ; Wed, 17 Aug 2022 19:47:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 178E43858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660765626; bh=1n55pVNmuOGWVDcROI2zL/Wp9eLm2EHkPGJp9Ic7w8w=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=h2UykquJS0BUytwjRAvA8Xu58u5I102KTYE3A2gkGo+wjmKgQF73sVJ0bzYgLq8T0 1mv/61+S01iNYSolfXsyXX6UBfm5gMWI0dGgd+IyMqG69+iQgDupigASLtSjqdvEvB fxj08iGoVSA/sT3jK0yQTsqlN73djtMKZtpxDdNQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id BED653858283 for ; Wed, 17 Aug 2022 19:46:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BED653858283 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-394-QYgRu_Z8NuO52oyDPxvznA-1; Wed, 17 Aug 2022 15:46:22 -0400 X-MC-Unique: QYgRu_Z8NuO52oyDPxvznA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27272299E757 for ; Wed, 17 Aug 2022 19:46:22 +0000 (UTC) Received: from pdp-11.redhat.com (unknown [10.22.16.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1142340CF8E4 for ; Wed, 17 Aug 2022 19:46:22 +0000 (UTC) To: GCC Patches Subject: [pushed] c++: Add new std::move test [PR67906] Date: Wed, 17 Aug 2022 15:46:16 -0400 Message-Id: <20220817194616.1642511-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Marek Polacek via Gcc-patches From: Marek Polacek Reply-To: Marek Polacek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1741438981871195227?= X-GMAIL-MSGID: =?utf-8?q?1741438981871195227?= 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 base-commit: 5adfb6540db95da5faf1f77fbe9ec38b4cf8eb1f 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 + struct remove_reference + { typedef _Tp type; }; + + template + struct remove_reference<_Tp&> + { typedef _Tp type; }; + + template + struct remove_reference<_Tp&&> + { typedef _Tp type; }; + + template + constexpr typename std::remove_reference<_Tp>::type&& + move(_Tp&& __t) noexcept + { return static_cast::type&&>(__t); } +} + +struct X { + X() { } + X(const X&) { } + X(const X&&) { } +}; + +const X x; +const X y = std::move(x);