Commit 6e48db73 by Jonathan Wakely Committed by Jonathan Wakely

memory: Include auto_ptr.h later.

	* 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.

From-SVN: r190109
parent cbd782e1
2012-08-03 Jonathan Wakely <jwakely.gcc@gmail.com>
* 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.
2012-07-30 François Dumont <fdumont@gcc.gnu.org> 2012-07-30 François Dumont <fdumont@gcc.gnu.org>
* include/bits/c++config (_GLIBCXX_END_NAMESPACE_CONTAINER): Fix * include/bits/c++config (_GLIBCXX_END_NAMESPACE_CONTAINER): Fix
......
// auto_ptr implementation -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -289,6 +289,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -289,6 +289,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef void element_type; typedef void element_type;
} _GLIBCXX_DEPRECATED; } _GLIBCXX_DEPRECATED;
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<_Lock_policy _Lp>
template<typename _Tp>
inline
__shared_count<_Lp>::__shared_count(std::auto_ptr<_Tp>&& __r)
: _M_pi(new _Sp_counted_ptr<_Tp*, _Lp>(__r.get()))
{ __r.release(); }
template<typename _Tp, _Lock_policy _Lp>
template<typename _Tp1>
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<typename _Tp>
template<typename _Tp1>
inline
shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Tp1>&& __r)
: __shared_ptr<_Tp>(std::move(__r)) { }
template<typename _Tp, typename _Dp>
template<typename _Up, typename>
inline
unique_ptr<_Tp, _Dp>::unique_ptr(auto_ptr<_Up>&& __u) noexcept
: _M_t(__u.release(), deleter_type()) { }
#endif
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace } // namespace
......
// shared_ptr and weak_ptr implementation -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -250,8 +250,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -250,8 +250,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if _GLIBCXX_USE_DEPRECATED #if _GLIBCXX_USE_DEPRECATED
template<typename _Tp1> template<typename _Tp1>
shared_ptr(std::auto_ptr<_Tp1>&& __r) shared_ptr(std::auto_ptr<_Tp1>&& __r);
: __shared_ptr<_Tp>(std::move(__r)) { }
#endif #endif
template<typename _Tp1, typename _Del> template<typename _Tp1, typename _Del>
......
// shared_ptr and weak_ptr implementation details -*- C++ -*- // shared_ptr and weak_ptr implementation details -*- C++ -*-
// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 // Copyright (C) 2007-2012 Free Software Foundation, Inc.
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -54,6 +53,10 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -54,6 +53,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if _GLIBCXX_USE_DEPRECATED
template<typename> class auto_ptr;
#endif
/** /**
* @brief Exception possibly thrown by @c shared_ptr. * @brief Exception possibly thrown by @c shared_ptr.
* @ingroup exceptions * @ingroup exceptions
...@@ -537,9 +540,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -537,9 +540,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Special case for auto_ptr<_Tp> to provide the strong guarantee. // Special case for auto_ptr<_Tp> to provide the strong guarantee.
template<typename _Tp> template<typename _Tp>
explicit explicit
__shared_count(std::auto_ptr<_Tp>&& __r) __shared_count(std::auto_ptr<_Tp>&& __r);
: _M_pi(new _Sp_counted_ptr<_Tp*, _Lp>(__r.get()))
{ __r.release(); }
#endif #endif
// Special case for unique_ptr<_Tp,_Del> to provide the strong guarantee. // Special case for unique_ptr<_Tp,_Del> to provide the strong guarantee.
...@@ -859,15 +860,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -859,15 +860,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if _GLIBCXX_USE_DEPRECATED #if _GLIBCXX_USE_DEPRECATED
// Postcondition: use_count() == 1 and __r.get() == 0 // Postcondition: use_count() == 1 and __r.get() == 0
template<typename _Tp1> template<typename _Tp1>
__shared_ptr(std::auto_ptr<_Tp1>&& __r) __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);
}
#endif #endif
/* TODO: use delegating constructor */ /* TODO: use delegating constructor */
......
// unique_ptr implementation -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -45,6 +45,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -45,6 +45,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @{ * @{
*/ */
#if _GLIBCXX_USE_DEPRECATED
template<typename> class auto_ptr;
#endif
/// Primary template, default_delete. /// Primary template, default_delete.
template<typename _Tp> template<typename _Tp>
struct default_delete struct default_delete
...@@ -161,8 +165,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -161,8 +165,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
std::enable_if<std::is_convertible<_Up*, _Tp*>::value std::enable_if<std::is_convertible<_Up*, _Tp*>::value
&& std::is_same<_Dp, && std::is_same<_Dp,
default_delete<_Tp>>::value>::type> default_delete<_Tp>>::value>::type>
unique_ptr(auto_ptr<_Up>&& __u) noexcept unique_ptr(auto_ptr<_Up>&& __u) noexcept;
: _M_t(__u.release(), deleter_type()) { }
#endif #endif
// Destructor. // Destructor.
......
// <future> -*- C++ -*- // <future> -*- 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -36,14 +36,16 @@ ...@@ -36,14 +36,16 @@
#else #else
#include <functional> #include <functional>
#include <memory>
#include <mutex> #include <mutex>
#include <thread> #include <thread>
#include <condition_variable> #include <condition_variable>
#include <system_error> #include <system_error>
#include <exception>
#include <atomic> #include <atomic>
#include <bits/functexcept.h> #include <bits/functexcept.h>
#include <bits/unique_ptr.h>
#include <bits/shared_ptr.h>
#include <bits/uses_allocator.h>
#include <bits/alloc_traits.h>
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
......
// <memory> -*- C++ -*- // <memory> -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, // Copyright (C) 2001-2012 Free Software Foundation, Inc.
// 2009, 2010, 2011
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -80,11 +78,11 @@ ...@@ -80,11 +78,11 @@
# include <type_traits> # include <type_traits>
# include <functional> # include <functional>
# include <debug/debug.h> # include <debug/debug.h>
# include <bits/unique_ptr.h>
# include <bits/shared_ptr.h>
# if _GLIBCXX_USE_DEPRECATED # if _GLIBCXX_USE_DEPRECATED
# include <backward/auto_ptr.h> # include <backward/auto_ptr.h>
# endif # endif
# include <bits/unique_ptr.h>
# include <bits/shared_ptr.h>
#else #else
# include <backward/auto_ptr.h> # include <backward/auto_ptr.h>
#endif #endif
......
// { dg-options "-std=gnu++0x " } // { dg-options "-std=gnu++0x " }
// { dg-do compile } // { 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -27,4 +27,4 @@ struct D : B { }; ...@@ -27,4 +27,4 @@ struct D : B { };
D d; D d;
std::default_delete<B[]> db; std::default_delete<B[]> db;
typedef decltype(db(&d)) type; // { dg-error "use of deleted function" } typedef decltype(db(&d)) type; // { dg-error "use of deleted function" }
// { dg-error "declared here" "" { target *-*-* } 83 } // { dg-error "declared here" "" { target *-*-* } 87 }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// { dg-do compile } // { 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -32,9 +32,9 @@ void test01() ...@@ -32,9 +32,9 @@ void test01()
{ {
X* px = 0; X* px = 0;
std::shared_ptr<X> p1(px); // { dg-error "here" } std::shared_ptr<X> p1(px); // { dg-error "here" }
// { dg-error "incomplete" "" { target *-*-* } 775 } // { dg-error "incomplete" "" { target *-*-* } 776 }
std::shared_ptr<X> p9(ap()); // { dg-error "here" } std::shared_ptr<X> p9(ap()); // { dg-error "here" }
// { dg-error "incomplete" "" { target *-*-* } 869 } // { dg-error "incomplete" "" { target *-*-* } 310 }
} }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// { dg-do compile } // { 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -41,10 +41,10 @@ void f() ...@@ -41,10 +41,10 @@ void f()
std::unique_ptr<int, B&> ub(nullptr, b); std::unique_ptr<int, B&> ub(nullptr, b);
std::unique_ptr<int, D&> ud(nullptr, d); std::unique_ptr<int, D&> ud(nullptr, d);
ub = std::move(ud); ub = std::move(ud);
// { dg-error "use of deleted function" "" { target *-*-* } 189 } // { dg-error "use of deleted function" "" { target *-*-* } 192 }
std::unique_ptr<int[], B&> uba(nullptr, b); std::unique_ptr<int[], B&> uba(nullptr, b);
std::unique_ptr<int[], D&> uda(nullptr, d); std::unique_ptr<int[], D&> uda(nullptr, d);
uba = std::move(uda); uba = std::move(uda);
// { dg-error "use of deleted function" "" { target *-*-* } 329 } // { dg-error "use of deleted function" "" { target *-*-* } 332 }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment