diff options
author | Jonathan Wakely <jwakely.gcc@gmail.com> | 2010-12-14 22:13:26 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2010-12-14 22:13:26 +0000 |
commit | 86137e8127767846e7a3a686273d454cc342d6e1 (patch) | |
tree | 2e0d2414be5097b1fc5fde696391c485b6fb7da2 | |
parent | 9ecfa8de88025917ab3442db65caf62abd46d538 (diff) | |
download | gcc-86137e8127767846e7a3a686273d454cc342d6e1.zip gcc-86137e8127767846e7a3a686273d454cc342d6e1.tar.gz gcc-86137e8127767846e7a3a686273d454cc342d6e1.tar.bz2 |
re PR libstdc++/46910 (std::shared_ptr requires public destructor for a class with friend deleter)
2010-12-14 Jonathan Wakely <jwakely.gcc@gmail.com>
PR libstdc++/46910
* include/bits/shared_ptr_base.h (_Sp_counted_deleter): Do not
derive from _Sp_counted_ptr.
* testsuite/20_util/shared_ptr/cons/46910.cc: New.
* testsuite/20_util/shared_ptr/cons/43820.cc: Adjust.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust.
From-SVN: r167819
-rw-r--r-- | libstdc++-v3/ChangeLog | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/shared_ptr_base.h | 16 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc | 46 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc | 2 |
5 files changed, 65 insertions, 12 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 95b19b0..548a4ee 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2010-12-14 Jonathan Wakely <jwakely.gcc@gmail.com> + + PR libstdc++/46910 + * include/bits/shared_ptr_base.h (_Sp_counted_deleter): Do not + derive from _Sp_counted_ptr. + * testsuite/20_util/shared_ptr/cons/46910.cc: New. + * testsuite/20_util/shared_ptr/cons/43820.cc: Adjust. + * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust. + 2010-12-13 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> * config/abi/post/solaris2.8/baseline_symbols.txt: Regenerate. diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index da18147..b333357 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -318,7 +318,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // Support for custom deleter and/or allocator template<typename _Ptr, typename _Deleter, typename _Alloc, _Lock_policy _Lp> - class _Sp_counted_deleter : public _Sp_counted_ptr<_Ptr, _Lp> + class _Sp_counted_deleter : public _Sp_counted_base<_Lp> { typedef typename _Alloc::template rebind<_Sp_counted_deleter>::other _My_alloc_type; @@ -334,21 +334,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std) : _My_alloc_type(__a), _M_del(__d) { } }; - protected: - typedef _Sp_counted_ptr<_Ptr, _Lp> _Base_type; - public: // __d(__p) must not throw. _Sp_counted_deleter(_Ptr __p, _Deleter __d) - : _Base_type(__p), _M_del(__d, _Alloc()) { } + : _M_ptr(__p), _M_del(__d, _Alloc()) { } // __d(__p) must not throw. _Sp_counted_deleter(_Ptr __p, _Deleter __d, const _Alloc& __a) - : _Base_type(__p), _M_del(__d, __a) { } + : _M_ptr(__p), _M_del(__d, __a) { } virtual void _M_dispose() // nothrow - { _M_del._M_del(_Base_type::_M_ptr); } + { _M_del._M_del(_M_ptr); } virtual void _M_destroy() // nothrow @@ -369,6 +366,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) } protected: + _Ptr _M_ptr; // copy constructor must not throw _My_Deleter _M_del; // copy constructor must not throw }; @@ -397,7 +395,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { void* __p = &_M_storage; ::new (__p) _Tp(); // might throw - _Base_type::_Base_type::_M_ptr = static_cast<_Tp*>(__p); + _Base_type::_M_ptr = static_cast<_Tp*>(__p); } template<typename... _Args> @@ -407,7 +405,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { void* __p = &_M_storage; ::new (__p) _Tp(std::forward<_Args>(__args)...); // might throw - _Base_type::_Base_type::_M_ptr = static_cast<_Tp*>(__p); + _Base_type::_M_ptr = static_cast<_Tp*>(__p); } // Override because the allocator needs to know the dynamic type diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc index 538126f..837c668 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc @@ -32,9 +32,9 @@ void test01() { X* px = 0; std::shared_ptr<X> p1(px); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 765 } + // { dg-error "incomplete" "" { target *-*-* } 763 } std::shared_ptr<X> p9(ap()); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 857 } + // { dg-error "incomplete" "" { target *-*-* } 855 } } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc new file mode 100644 index 0000000..d827519 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 20.9.10.2 Class template shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +// 20.9.10.2.1 shared_ptr constructors [util.smartptr.shared.const] + +struct deleter; + +class A +{ + ~A() = default; + friend struct deleter; +}; + +struct deleter +{ + void operator()(A* a) const; +}; + +void +test01() +{ + std::shared_ptr<A> p(new A, deleter()); +} + diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc index c26b09d..357e32f 100644 --- a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc @@ -43,7 +43,7 @@ main() } // { dg-warning "note" "" { target *-*-* } 352 } -// { dg-warning "note" "" { target *-*-* } 1085 } +// { dg-warning "note" "" { target *-*-* } 1083 } // { dg-warning "note" "" { target *-*-* } 465 } // { dg-warning "note" "" { target *-*-* } 585 } // { dg-warning "note" "" { target *-*-* } 1048 } |