OSDN Git Service

2010-12-14 Jonathan Wakely <jwakely.gcc@gmail.com>
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 2010 22:13:26 +0000 (22:13 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 2010 22:13:26 +0000 (22:13 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167819 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/shared_ptr_base.h
libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc
libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc

index 95b19b0..548a4ee 100644 (file)
@@ -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.
 2010-12-13  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * config/abi/post/solaris2.8/baseline_symbols.txt: Regenerate.
index da18147..b333357 100644 (file)
@@ -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>
 
   // 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;
     {
       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) { }
       };
 
        : _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)
     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)
 
       // __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
 
       virtual void
       _M_dispose() // nothrow
-      { _M_del._M_del(_Base_type::_M_ptr); }
+      { _M_del._M_del(_M_ptr); }
 
       virtual void
       _M_destroy() // nothrow
 
       virtual void
       _M_destroy() // nothrow
@@ -369,6 +366,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       }
 
     protected:
       }
 
     protected:
+      _Ptr             _M_ptr;  // copy constructor must not throw
       _My_Deleter      _M_del;  // 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
       {
        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>
       }
 
       template<typename... _Args>
@@ -407,7 +405,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        {
          void* __p = &_M_storage;
          ::new (__p) _Tp(std::forward<_Args>(__args)...);  // might throw
        {
          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
        }
 
       // Override because the allocator needs to know the dynamic type
index 538126f..837c668 100644 (file)
@@ -32,9 +32,9 @@ void test01()
 {
   X* px = 0;
   std::shared_ptr<X> p1(px);   // { dg-error "here" }
 {
   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" }
 
   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 (file)
index 0000000..d827519
--- /dev/null
@@ -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());
+}
+
index c26b09d..357e32f 100644 (file)
@@ -43,7 +43,7 @@ main()
 }
 
 // { dg-warning "note" "" { target *-*-* } 352 }
 }
 
 // { 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 }
 // { dg-warning "note" "" { target *-*-* } 465 }
 // { dg-warning "note" "" { target *-*-* } 585 }
 // { dg-warning "note" "" { target *-*-* } 1048 }