aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons')
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc30
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc107
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc103
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc49
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc48
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc136
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc46
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc164
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc80
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc49
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc59
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc60
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc63
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc48
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc51
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc62
16 files changed, 1155 insertions, 0 deletions
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc
new file mode 100644
index 000000000..d5b3f7dea
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc
@@ -0,0 +1,30 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2009 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/>.
+
+#include <memory>
+
+// libstdc++/39405
+template<typename T>
+ struct foo
+ {
+ std::shared_ptr<foo<T> > m_foo;
+ };
+
+std::shared_ptr<foo<int> > t;
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc
new file mode 100644
index 000000000..9c39ed50d
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc
@@ -0,0 +1,107 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() : i() { }
+ virtual ~A() { }
+ int i;
+};
+
+struct B : A
+{
+ B() : A(), a() { }
+ virtual ~B() { }
+ A a;
+};
+
+void deletefunc(A* p) { delete p; }
+
+// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Aliasing constructors
+
+int test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<A> a;
+ std::shared_ptr<bool> b1(a, &test);
+ VERIFY( b1.use_count() == 0 );
+ VERIFY( a.get() == 0 );
+ VERIFY( b1.get() == &test );
+
+ std::shared_ptr<bool> b2(b1);
+ VERIFY( b2.use_count() == 0 );
+ VERIFY( b1.get() == b2.get() );
+
+ return 0;
+}
+
+int
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<A> a(new A);
+ std::shared_ptr<int> i1(a, &a->i);
+ VERIFY( i1.use_count() == 2 );
+
+ std::shared_ptr<int> i2(i1);
+ VERIFY( i2.use_count() == 3 );
+ VERIFY( i2.get() == &a->i );
+
+ return 0;
+}
+
+int
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<B> b(new B);
+ std::shared_ptr<A> a1(b, b.get());
+ std::shared_ptr<A> a2(b, &b->a);
+ VERIFY( a2.use_count() == 3 );
+ VERIFY( a1 == b );
+ VERIFY( a2 != b );
+ VERIFY( a1.get() != a2.get() );
+
+ std::shared_ptr<A> a3(a1);
+ VERIFY( a3 == b );
+
+ a3 = a2;
+ VERIFY( a3.get() == &b->a );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc
new file mode 100644
index 000000000..4a4be9a68
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc
@@ -0,0 +1,103 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+using __gnu_test::tracker_allocator_counter;
+using __gnu_test::tracker_allocator;
+
+struct A { };
+void deletefunc(A* p) { delete p; }
+struct D
+{
+ void operator()(A* p) { delete p; ++delete_count; }
+ static long delete_count;
+};
+long D::delete_count = 0;
+
+// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Construction with allocator
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ tracker_allocator_counter::reset();
+
+ std::shared_ptr<A> p1(new A, deletefunc, tracker_allocator<A>());
+ std::size_t const sz = tracker_allocator_counter::get_allocation_count();
+ VERIFY( sz > 0 );
+ {
+ std::shared_ptr<A> p2(p1);
+ VERIFY( p2.use_count() == 2 );
+ VERIFY( tracker_allocator_counter::get_allocation_count() == sz );
+ VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 );
+ }
+ VERIFY( p1.use_count() == 1 );
+ VERIFY( tracker_allocator_counter::get_allocation_count() == sz );
+ VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 );
+ p1.reset();
+ VERIFY( p1.use_count() == 0 );
+ VERIFY( tracker_allocator_counter::get_allocation_count() == sz );
+ VERIFY( tracker_allocator_counter::get_deallocation_count() == sz );
+
+ return 0;
+}
+
+// Construction with allocator
+int
+test02()
+{
+ bool test __attribute__((unused)) = true;
+ tracker_allocator_counter::reset();
+
+ std::shared_ptr<A> p1(new A, deletefunc, tracker_allocator<A>());
+ std::size_t const sz1 = tracker_allocator_counter::get_allocation_count();
+ VERIFY( sz1 > 0 );
+ std::shared_ptr<A> p2(new A, D(), tracker_allocator<A>());
+ std::size_t const sz2 = tracker_allocator_counter::get_allocation_count();
+ VERIFY( sz2 > sz1 );
+ VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 );
+ p1 = p2;
+ VERIFY( p2.use_count() == 2 );
+ VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 );
+ VERIFY( tracker_allocator_counter::get_deallocation_count() == sz1 );
+ p1.reset();
+ VERIFY( p2.use_count() == 1 );
+ VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 );
+ VERIFY( tracker_allocator_counter::get_deallocation_count() == sz1 );
+ p2.reset();
+ VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 );
+ VERIFY( tracker_allocator_counter::get_deallocation_count() == sz2 );
+ VERIFY( D::delete_count == 1 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc
new file mode 100644
index 000000000..9087e518a
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc
@@ -0,0 +1,49 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Construction from auto_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::auto_ptr<A> a(new A);
+ std::shared_ptr<A> a2(a);
+ VERIFY( a.get() == 0 );
+ VERIFY( a2.get() != 0 );
+ VERIFY( a2.use_count() == 1 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc
new file mode 100644
index 000000000..3a946b587
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc
@@ -0,0 +1,48 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.const]
+
+// Construction from const auto_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::auto_ptr<A> a;
+ std::shared_ptr<A> p(a); // { dg-error "no match" }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+// { dg-excess-errors "candidates are" }
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc
new file mode 100644
index 000000000..c5dcffea0
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc
@@ -0,0 +1,136 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ virtual ~A() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long A::ctor_count = 0;
+long A::dtor_count = 0;
+
+struct B : A
+{
+ B() { ++ctor_count; }
+ virtual ~B() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long B::ctor_count = 0;
+long B::dtor_count = 0;
+
+void deleter(A* p) { delete p; }
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Copy construction
+int test01()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<A> a1;
+ std::shared_ptr<A> a2(a1);
+ VERIFY( a2.use_count() == 0 );
+ VERIFY( A::ctor_count == 0 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+test02()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<A> a1(new A);
+ std::shared_ptr<A> a2(a1);
+ VERIFY( a2.use_count() == 2 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+test03()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<B> b(new B);
+ std::shared_ptr<A> a(b);
+ VERIFY( a.use_count() == 2 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+test04()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<B> b(new B, &deleter);
+ std::shared_ptr<A> a(b);
+ VERIFY( a.use_count() == 2 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc
new file mode 100644
index 000000000..ec4c1fdab
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Default construction
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<A> a;
+ VERIFY( a.get() == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc
new file mode 100644
index 000000000..795155829
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc
@@ -0,0 +1,164 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2009 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/>.
+
+// TR1 20.6.6.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <utility>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ virtual ~A() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long A::ctor_count = 0;
+long A::dtor_count = 0;
+
+struct B : A
+{
+ B() { ++ctor_count; }
+ virtual ~B() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long B::ctor_count = 0;
+long B::dtor_count = 0;
+
+struct D
+{
+ void operator()(B* p) const { delete p; ++delete_count; }
+ static long delete_count;
+};
+long D::delete_count = 0;
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ D::delete_count = 0;
+ }
+};
+
+// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Rvalue construction
+int test01()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<A> a1;
+ std::shared_ptr<A> a2(std::move(a1));
+ VERIFY( a1.use_count() == 0 );
+ VERIFY( a2.use_count() == 0 );
+ VERIFY( A::ctor_count == 0 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+test02()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<A> a1(new A);
+ std::shared_ptr<A> a2(std::move(a1));
+ VERIFY( a1.use_count() == 0 );
+ VERIFY( a2.use_count() == 1 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+test03()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<B> b(new B);
+ std::shared_ptr<A> a(std::move(b));
+ VERIFY( b.use_count() == 0 );
+ VERIFY( a.use_count() == 1 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+test04()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<B> b(new B, D());
+ std::shared_ptr<A> a(std::move(b));
+ VERIFY( b.use_count() == 0 );
+ VERIFY( a.use_count() == 1 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 0 );
+
+ a = std::move(std::shared_ptr<A>());
+ VERIFY( D::delete_count == 1 );
+ VERIFY( B::dtor_count == 1 );
+
+ return 0;
+}
+
+int
+test05()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<A> a(std::move(std::shared_ptr<A>(new A)));
+ VERIFY( a.use_count() == 1 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ test05();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc
new file mode 100644
index 000000000..4bb528011
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc
@@ -0,0 +1,80 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+struct B : A { };
+
+
+// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Construction from pointer
+
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a = 0;
+ std::shared_ptr<A> p(a);
+ VERIFY( p.get() == 0 );
+ VERIFY( p.use_count() == 1 );
+
+ return 0;
+}
+
+int
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a = new A;
+ std::shared_ptr<A> p(a);
+ VERIFY( p.get() == a );
+ VERIFY( p.use_count() == 1 );
+
+ return 0;
+}
+
+
+int
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ B * const b = new B;
+ std::shared_ptr<A> p(b);
+ VERIFY( p.get() == b );
+ VERIFY( p.use_count() == 1 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test02();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc
new file mode 100644
index 000000000..cfca90d90
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc
@@ -0,0 +1,49 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Construction from unique_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A> up(new A);
+ std::shared_ptr<A> sp(std::move(up));
+ VERIFY( up.get() == 0 );
+ VERIFY( sp.get() != 0 );
+ VERIFY( sp.use_count() == 1 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc
new file mode 100644
index 000000000..67485aee7
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc
@@ -0,0 +1,59 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+struct D {
+ void operator()(A* p) const { delete p; ++count; }
+ static int count;
+};
+
+int D::count = 0;
+
+// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Construction from unique_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A, D> up(new A, D());
+ {
+ std::shared_ptr<A> sp(std::move(up));
+ VERIFY( up.get() == 0 );
+ VERIFY( sp.get() != 0 );
+ VERIFY( sp.use_count() == 1 );
+ }
+ VERIFY( D::count == 1 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc
new file mode 100644
index 000000000..d0998c94c
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc
@@ -0,0 +1,60 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+struct D {
+ typedef void result_type;
+ void operator()(A* p) { delete p; ++count; }
+ int count;
+};
+
+
+// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Construction from unique_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ D d = D();
+ std::unique_ptr<A, D&> up(new A, d);
+ {
+ std::shared_ptr<A> sp(std::move(up));
+ VERIFY( up.get() == 0 );
+ VERIFY( sp.get() != 0 );
+ VERIFY( sp.use_count() == 1 );
+ }
+ VERIFY( d.count == 1 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc
new file mode 100644
index 000000000..7b09cfa7d
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc
@@ -0,0 +1,63 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <functional>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+struct D {
+ typedef void result_type;
+ void operator()(A* p) { delete p; ++count; }
+ int count;
+};
+
+
+// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Construction from unique_ptr
+// See: http://gcc.gnu.org/ml/libstdc++/2008-09/msg00070.html.
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ D d;
+ std::unique_ptr<A, D&> p1(new A, d);
+
+ std::shared_ptr<A> p2(std::move(p1));
+
+ typedef std::reference_wrapper<D> D2;
+ D2* p3 = std::get_deleter<D2>(p2);
+
+ VERIFY( p3 != 0 );
+ VERIFY( &p3->get() == &d );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc
new file mode 100644
index 000000000..37bdb0b87
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc
@@ -0,0 +1,48 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2008, 2009 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.7.12.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Construction from lvalue unique_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A> a;
+ std::shared_ptr<A> p(a); // { dg-error "used here" }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+// { dg-excess-errors "deleted function" }
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc
new file mode 100644
index 000000000..7e24c1822
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc
@@ -0,0 +1,51 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Construction from weak_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a = new A;
+ std::shared_ptr<A> a1(a);
+ std::weak_ptr<A> wa(a1);
+ std::shared_ptr<A> a2(wa);
+ VERIFY( a2.get() == a );
+ VERIFY( a2.use_count() == wa.use_count() );
+
+ return 0;
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc
new file mode 100644
index 000000000..cff9b3b99
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc
@@ -0,0 +1,62 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+// Copyright (C) 2005, 2006, 2007, 2009 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.6.6.2 Template class shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+// Construction from expired weak_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::shared_ptr<A> a1(new A);
+ std::weak_ptr<A> wa(a1);
+ a1.reset();
+ VERIFY( wa.expired() );
+ try
+ {
+ std::shared_ptr<A> a2(wa);
+ }
+ catch (const std::bad_weak_ptr&)
+ {
+ // Expected.
+ __throw_exception_again;
+ }
+ catch (...)
+ {
+ // Failed.
+ }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}