From patchwork Fri Aug 3 00:28:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 174820 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 142602C007B for ; Fri, 3 Aug 2012 10:29:15 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1344558556; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=Sx0FUSM 4c8nbKcB8OVLObYV3UGI=; b=OnTksXKEyhms/3a5+rXGc83oPnW2wyPvCv7JlF/ OZJoYfhv2I2WZ7zbWwJjSRTFJXtdWA1HTY4L8cQqwiAWSbkorbxYfejMf8vVFRIw SYwVJfGJrasUsBDE8QJA0VI5ZazbzMlJVY1eIa6+SaDmv7NCCNYkhYxl1t8c57P1 EE2g= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=BZ2eR4U7m9M91wpllqSaIV5dd6INmHDrXp4wF0BhRiXmRaovsl5TD9iBhd8872 MMZ1NbDcGedg9u/U9HFsNxAjmk3/rHTuct5u40GIrFtjUjnROAaAxb6y5FCwM6rM UZAJwe9L+kukHKzeE9pcCtKTHG1zQpqf79910NBnsdWCg=; Received: (qmail 6499 invoked by alias); 3 Aug 2012 00:29:08 -0000 Received: (qmail 6480 invoked by uid 22791); 3 Aug 2012 00:29:06 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-gg0-f175.google.com (HELO mail-gg0-f175.google.com) (209.85.161.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Aug 2012 00:28:46 +0000 Received: by ggmq1 with SMTP id q1so172532ggm.20 for ; Thu, 02 Aug 2012 17:28:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.195.234 with SMTP id ih10mr5959336igc.0.1343953725505; Thu, 02 Aug 2012 17:28:45 -0700 (PDT) Received: by 10.43.114.201 with HTTP; Thu, 2 Aug 2012 17:28:45 -0700 (PDT) Date: Fri, 3 Aug 2012 01:28:45 +0100 Message-ID: Subject: [v3] reorder headers in From: Jonathan Wakely To: "libstdc++" , gcc-patches 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 As suggested a few weeks ago on the libstdc++ list, this patch tweaks the include order in , allowing internal library headers to use shared_ptr and unique_ptr without depending on . * include/std/memory: Include auto_ptr.h later. * include/bits/shared_ptr.h (shared_ptr(auto_ptr<_Up>&&): Remove definition. * include/bits/shared_ptr_base.h (__shared_ptr(auto_ptr<_Up>&&): Likewise. * include/bits/unique_ptr.h (unique_ptr(auto_ptr<_Up>&&): Likewise. * include/backward/auto_ptr.h (unique_ptr(auto_ptr<_Up>&&): Define. (shared_ptr(auto_ptr<_Up>&&, __shared_ptr(auto_ptr<_Up>&&): Likewise. * include/std/future: Reduce header dependencies. * testsuite/20_util/default_delete/48631_neg.cc: Adjust dg-error line numbers. * testsuite/20_util/shared_ptr/cons/43820_neg.cc: Likewise. * testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise. Tested x86_64-linux, committed to trunk. commit 9386ced4bfd9990046d2dec6a080478c8cc01c50 Author: Jonathan Wakely Date: Fri Aug 3 01:25:19 2012 +0100 * include/std/memory: Include auto_ptr.h later. * include/bits/shared_ptr.h (shared_ptr(auto_ptr<_Up>&&): Remove definition. * include/bits/shared_ptr_base.h (__shared_ptr(auto_ptr<_Up>&&): Likewise. * include/bits/unique_ptr.h (unique_ptr(auto_ptr<_Up>&&): Likewise. * include/backward/auto_ptr.h (unique_ptr(auto_ptr<_Up>&&): Define. (shared_ptr(auto_ptr<_Up>&&, __shared_ptr(auto_ptr<_Up>&&): Likewise. * include/std/future: Reduce header dependencies. * testsuite/20_util/default_delete/48631_neg.cc: Adjust dg-error line numbers. * testsuite/20_util/shared_ptr/cons/43820_neg.cc: Likewise. * testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise. diff --git a/libstdc++-v3/include/backward/auto_ptr.h b/libstdc++-v3/include/backward/auto_ptr.h index 3c91c08..01702f7 100644 --- a/libstdc++-v3/include/backward/auto_ptr.h +++ b/libstdc++-v3/include/backward/auto_ptr.h @@ -1,6 +1,6 @@ // auto_ptr implementation -*- C++ -*- -// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2007-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -289,6 +289,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef void element_type; } _GLIBCXX_DEPRECATED; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<_Lock_policy _Lp> + template + inline + __shared_count<_Lp>::__shared_count(std::auto_ptr<_Tp>&& __r) + : _M_pi(new _Sp_counted_ptr<_Tp*, _Lp>(__r.get())) + { __r.release(); } + + template + template + inline + __shared_ptr<_Tp, _Lp>::__shared_ptr(std::auto_ptr<_Tp1>&& __r) + : _M_ptr(__r.get()), _M_refcount() + { + __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) + static_assert( sizeof(_Tp1) > 0, "incomplete type" ); + _Tp1* __tmp = __r.get(); + _M_refcount = __shared_count<_Lp>(std::move(__r)); + __enable_shared_from_this_helper(_M_refcount, __tmp, __tmp); + } + + template + template + inline + shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Tp1>&& __r) + : __shared_ptr<_Tp>(std::move(__r)) { } + + template + template + inline + unique_ptr<_Tp, _Dp>::unique_ptr(auto_ptr<_Up>&& __u) noexcept + : _M_t(__u.release(), deleter_type()) { } +#endif + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h index 070d2d1..e1c1eb9 100644 --- a/libstdc++-v3/include/bits/shared_ptr.h +++ b/libstdc++-v3/include/bits/shared_ptr.h @@ -1,6 +1,6 @@ // shared_ptr and weak_ptr implementation -*- C++ -*- -// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2007-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -250,8 +250,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if _GLIBCXX_USE_DEPRECATED template - shared_ptr(std::auto_ptr<_Tp1>&& __r) - : __shared_ptr<_Tp>(std::move(__r)) { } + shared_ptr(std::auto_ptr<_Tp1>&& __r); #endif template diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 39449f1..1ccd5ef 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -1,7 +1,6 @@ // shared_ptr and weak_ptr implementation details -*- C++ -*- -// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 -// Free Software Foundation, Inc. +// Copyright (C) 2007-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -54,6 +53,10 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#if _GLIBCXX_USE_DEPRECATED + template class auto_ptr; +#endif + /** * @brief Exception possibly thrown by @c shared_ptr. * @ingroup exceptions @@ -537,9 +540,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Special case for auto_ptr<_Tp> to provide the strong guarantee. template explicit - __shared_count(std::auto_ptr<_Tp>&& __r) - : _M_pi(new _Sp_counted_ptr<_Tp*, _Lp>(__r.get())) - { __r.release(); } + __shared_count(std::auto_ptr<_Tp>&& __r); #endif // Special case for unique_ptr<_Tp,_Del> to provide the strong guarantee. @@ -859,15 +860,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if _GLIBCXX_USE_DEPRECATED // Postcondition: use_count() == 1 and __r.get() == 0 template - __shared_ptr(std::auto_ptr<_Tp1>&& __r) - : _M_ptr(__r.get()), _M_refcount() - { - __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) - static_assert( sizeof(_Tp1) > 0, "incomplete type" ); - _Tp1* __tmp = __r.get(); - _M_refcount = __shared_count<_Lp>(std::move(__r)); - __enable_shared_from_this_helper(_M_refcount, __tmp, __tmp); - } + __shared_ptr(std::auto_ptr<_Tp1>&& __r); #endif /* TODO: use delegating constructor */ diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index 0a12799..9b736d4 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -1,6 +1,6 @@ // unique_ptr implementation -*- C++ -*- -// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2008-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -45,6 +45,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ +#if _GLIBCXX_USE_DEPRECATED + template class auto_ptr; +#endif + /// Primary template, default_delete. template struct default_delete @@ -161,8 +165,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::enable_if::value && std::is_same<_Dp, default_delete<_Tp>>::value>::type> - unique_ptr(auto_ptr<_Up>&& __u) noexcept - : _M_t(__u.release(), deleter_type()) { } + unique_ptr(auto_ptr<_Up>&& __u) noexcept; #endif // Destructor. diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index 962400b..a8d7112 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2009-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -36,14 +36,16 @@ #else #include -#include #include #include #include #include -#include #include #include +#include +#include +#include +#include namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/std/memory b/libstdc++-v3/include/std/memory index e846eba..73482ff 100644 --- a/libstdc++-v3/include/std/memory +++ b/libstdc++-v3/include/std/memory @@ -1,8 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, -// 2009, 2010, 2011 -// Free Software Foundation, Inc. +// Copyright (C) 2001-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -80,11 +78,11 @@ # include # include # include +# include +# include # if _GLIBCXX_USE_DEPRECATED # include # endif -# include -# include #else # include #endif diff --git a/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc b/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc index 9d779ac..a9bba97 100644 --- a/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc +++ b/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc @@ -1,7 +1,7 @@ // { dg-options "-std=gnu++0x " } // { dg-do compile } -// Copyright (C) 2011 Free Software Foundation +// Copyright (C) 2011-2012 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -27,4 +27,4 @@ struct D : B { }; D d; std::default_delete db; typedef decltype(db(&d)) type; // { dg-error "use of deleted function" } -// { dg-error "declared here" "" { target *-*-* } 83 } +// { dg-error "declared here" "" { target *-*-* } 87 } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc index d2110ca..dc9d803 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc @@ -1,7 +1,7 @@ // { dg-options "-std=gnu++0x" } // { dg-do compile } -// Copyright (C) 2010, 2011, 2012 Free Software Foundation +// Copyright (C) 2010-2012 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -32,9 +32,9 @@ void test01() { X* px = 0; std::shared_ptr p1(px); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 775 } + // { dg-error "incomplete" "" { target *-*-* } 776 } std::shared_ptr p9(ap()); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 869 } + // { dg-error "incomplete" "" { target *-*-* } 310 } } diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc index 1ed53ee..d72821e 100644 --- a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc @@ -1,7 +1,7 @@ // { dg-options "-std=gnu++0x" } // { dg-do compile } -// Copyright (C) 2011 Free Software Foundation +// Copyright (C) 2011-2012 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -41,10 +41,10 @@ void f() std::unique_ptr ub(nullptr, b); std::unique_ptr ud(nullptr, d); ub = std::move(ud); -// { dg-error "use of deleted function" "" { target *-*-* } 189 } +// { dg-error "use of deleted function" "" { target *-*-* } 192 } std::unique_ptr uba(nullptr, b); std::unique_ptr uda(nullptr, d); uba = std::move(uda); -// { dg-error "use of deleted function" "" { target *-*-* } 329 } +// { dg-error "use of deleted function" "" { target *-*-* } 332 } }