From patchwork Thu Nov 17 16:24:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 126270 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 7FEBEB71DB for ; Fri, 18 Nov 2011 03:24:44 +1100 (EST) Received: (qmail 15499 invoked by alias); 17 Nov 2011 16:24:39 -0000 Received: (qmail 15485 invoked by uid 22791); 17 Nov 2011 16:24:36 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_CX X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 17 Nov 2011 16:24:22 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pAHGOMJn023014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Nov 2011 11:24:22 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pAHGOL3G003577; Thu, 17 Nov 2011 11:24:21 -0500 Received: from [0.0.0.0] (ovpn-113-90.phx2.redhat.com [10.3.113.90]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id pAHGOKb6009655; Thu, 17 Nov 2011 11:24:20 -0500 Message-ID: <4EC53533.6060409@redhat.com> Date: Thu, 17 Nov 2011 11:24:19 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111112 Thunderbird/8.0 MIME-Version: 1.0 To: gcc-patches List CC: Benjamin Kosnik Subject: C++ PATCH for implicit move conditions (N3203) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org At the Batavia meeting last year, the C++ committee changed the conditions for implicitly declaring move constructors/assignment ops; now they are suppressed by having any of (copy ctor/op=, move ctor/op=, dtor). I needed to make some adjustments to the libstdc++ testsuite as a result; bkoz, do these changes make sense to you? Tested x86_64-pc-linux-gnu, applying to trunk. commit 29f2248c817fa1469529c8c3089d742c25a0310f Author: Jason Merrill Date: Wed Nov 16 14:25:23 2011 -0500 N3203 * class.c (add_implicitly_declared_members): Update move conditions. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0765817..cb0e683 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2721,6 +2721,13 @@ add_implicitly_declared_members (tree t, int cant_have_const_cctor, int cant_have_const_assignment) { + bool move_ok = false; + + if (cxx_dialect >= cxx0x && !CLASSTYPE_DESTRUCTORS (t) + && !TYPE_HAS_COPY_CTOR (t) && !TYPE_HAS_COPY_ASSIGN (t) + && !type_has_move_constructor (t) && !type_has_move_assign (t)) + move_ok = true; + /* Destructor. */ if (!CLASSTYPE_DESTRUCTORS (t)) { @@ -2758,7 +2765,7 @@ add_implicitly_declared_members (tree t, TYPE_HAS_COPY_CTOR (t) = 1; TYPE_HAS_CONST_COPY_CTOR (t) = !cant_have_const_cctor; CLASSTYPE_LAZY_COPY_CTOR (t) = 1; - if (cxx_dialect >= cxx0x && !type_has_move_constructor (t)) + if (move_ok) CLASSTYPE_LAZY_MOVE_CTOR (t) = 1; } @@ -2771,7 +2778,7 @@ add_implicitly_declared_members (tree t, TYPE_HAS_COPY_ASSIGN (t) = 1; TYPE_HAS_CONST_COPY_ASSIGN (t) = !cant_have_const_assignment; CLASSTYPE_LAZY_COPY_ASSIGN (t) = 1; - if (cxx_dialect >= cxx0x && !type_has_move_assign (t)) + if (move_ok) CLASSTYPE_LAZY_MOVE_ASSIGN (t) = 1; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2.cc index 13cc4e5..2d1b4ca 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2.cc @@ -31,6 +31,7 @@ class tstring : public std::basic_string public: tstring() : std::basic_string() {} tstring(tstring&& s) : std::basic_string(std::move(s)) {} + tstring& operator=(tstring&& s) = default; }; void test01() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable2.cc index e0b8b24..42026c9 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable2.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable2.cc @@ -31,6 +31,7 @@ class twstring : public std::basic_string public: twstring() : std::basic_string() {} twstring(twstring&& s) : std::basic_string(std::move(s)) {} + twstring& operator=(twstring&&) = default; }; void test01() diff --git a/libstdc++-v3/testsuite/util/testsuite_tr1.h b/libstdc++-v3/testsuite/util/testsuite_tr1.h index f063896..1452e3e 100644 --- a/libstdc++-v3/testsuite/util/testsuite_tr1.h +++ b/libstdc++-v3/testsuite/util/testsuite_tr1.h @@ -199,6 +199,7 @@ namespace __gnu_test struct NoexceptMoveConsClass { NoexceptMoveConsClass(NoexceptMoveConsClass&&) noexcept(true); + NoexceptMoveConsClass& operator=(NoexceptMoveConsClass&&) = default; }; struct ExceptMoveConsClass @@ -220,6 +221,7 @@ namespace __gnu_test struct NoexceptMoveAssignClass { + NoexceptMoveAssignClass(NoexceptMoveAssignClass&&) = default; NoexceptMoveAssignClass& operator=(NoexceptMoveAssignClass&&) noexcept(true); };