summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/tr1/2_general_utilities
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/tr1/2_general_utilities
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/tr1/2_general_utilities')
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/1.cc38
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared.cc58
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared2.cc60
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared3.cc62
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc30
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/shared.cc45
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/still_shared.cc54
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/headers/functional/synopsis.cc34
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/headers/memory/synopsis.cc65
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/headers/memory/types_std_tr1.cc25
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/assign.cc70
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr.cc83
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_neg.cc49
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_rvalue_neg.cc48
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/dr541.cc29
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr.cc94
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr_neg.cc51
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/casts/1.cc45
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/comparison/cmp.cc82
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/39405.cc29
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc38
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr.cc47
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr_neg.cc47
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/copy.cc134
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/default.cc44
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/pointer.cc78
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr.cc49
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr_expired.cc60
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/dest/dest.cc132
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/24595.cc38
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/42019.cc35
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/io.cc50
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/swap.cc49
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/24805.cc29
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset.cc87
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset_neg.cc46
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap.cc49
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap_neg.cc47
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/bool_conv.cc79
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/get.cc79
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/unique.cc79
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/use_count.cc78
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc30
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/2.cc33
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc193
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc195
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/lock/1.cc35
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc30
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/2.cc34
49 files changed, 2975 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/1.cc
new file mode 100644
index 000000000..e4f6c8505
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/1.cc
@@ -0,0 +1,38 @@
+// 2006-09-24 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006, 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/>.
+
+// 2.2.5 Template class enable_shared_from_this [tr.util.smartptr.enab]
+
+#include <tr1/memory>
+#include <testsuite_tr1.h>
+
+// { dg-do compile }
+
+struct X : public std::tr1::enable_shared_from_this<X>
+{
+};
+
+int main()
+{
+ using __gnu_test::check_ret_type;
+ using std::tr1::shared_ptr;
+
+ shared_ptr<X> spx(new X);
+ check_ret_type<shared_ptr<X> >(spx->shared_from_this());
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared.cc
new file mode 100644
index 000000000..dc4b895d8
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared.cc
@@ -0,0 +1,58 @@
+// Copyright (C) 2005, 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/>.
+
+// 2.2.5 Template class enable_shared_from_this [tr.util.smartptr.enab]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct X : public std::tr1::enable_shared_from_this<X>
+{
+};
+
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ X x;
+
+ try
+ {
+ std::tr1::shared_ptr<X> p = x.shared_from_this();
+ VERIFY( false );
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ // Expected.
+ VERIFY( true );
+ }
+ catch (...)
+ {
+ // Failed.
+ VERIFY( false );
+ }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared2.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared2.cc
new file mode 100644
index 000000000..19d033346
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared2.cc
@@ -0,0 +1,60 @@
+// Copyright (C) 2005, 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/>.
+
+// 2.2.5 Template class enable_shared_from_this [tr.util.smartptr.enab]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct X : public std::tr1::enable_shared_from_this<X>
+{
+};
+
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<X> p(new X);
+
+ X x(*p); // copy of shared object should not be shared
+
+ try
+ {
+ std::tr1::shared_ptr<X> p = x.shared_from_this();
+ VERIFY( false );
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ // Expected.
+ VERIFY( true );
+ }
+ catch (...)
+ {
+ // Failed.
+ VERIFY( false );
+ }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared3.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared3.cc
new file mode 100644
index 000000000..8c58b049c
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared3.cc
@@ -0,0 +1,62 @@
+// Copyright (C) 2005, 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/>.
+
+// 2.2.5 Template class enable_shared_from_this [tr.util.smartptr.enab]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct X : public std::tr1::enable_shared_from_this<X>
+{
+};
+
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<X> p(new X);
+
+ X x;
+ x = *p; // copy of shared object should not be shared
+
+ try
+ {
+ std::tr1::shared_ptr<X> p = x.shared_from_this();
+ VERIFY( false );
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ // Expected.
+ VERIFY( true );
+ }
+ catch (...)
+ {
+ // Failed.
+ VERIFY( false );
+ }
+
+ return 0;
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc
new file mode 100644
index 000000000..b090c4ba7
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2006, 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 2.2.5 Template class enable_shared_from_this [tr.util.smartptr.enab]
+
+#include <tr1/memory>
+#include <testsuite_tr1.h>
+
+// { dg-do compile }
+
+using namespace __gnu_test;
+using std::tr1::enable_shared_from_this;
+template class enable_shared_from_this<int>;
+template class enable_shared_from_this<void>;
+template class enable_shared_from_this<ClassType>;
+template class enable_shared_from_this<IncompleteClass>;
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/shared.cc
new file mode 100644
index 000000000..3ea9d3e85
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/shared.cc
@@ -0,0 +1,45 @@
+// Copyright (C) 2005, 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/>.
+
+// 2.2.5 Template class enable_shared_from_this [tr.util.smartptr.enab]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct X : public std::tr1::enable_shared_from_this<X>
+{
+};
+
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<X> p(new X);
+ std::tr1::shared_ptr<X> q = p->shared_from_this();
+ VERIFY( p == q );
+ VERIFY( !(p < q) && !(q < p) ); // p and q share ownership
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/still_shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/still_shared.cc
new file mode 100644
index 000000000..beff2d4b7
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/still_shared.cc
@@ -0,0 +1,54 @@
+// Copyright (C) 2005, 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/>.
+
+// 2.2.5 Template class enable_shared_from_this [tr.util.smartptr.enab]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct X : public std::tr1::enable_shared_from_this<X>
+{
+};
+
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<X> p(new X);
+
+ *p = X(); // assigning to shared object doesn't stop it being shared
+
+ try
+ {
+ std::tr1::shared_ptr<X> p2 = p->shared_from_this();
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ test = false;
+ }
+ VERIFY( test );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/headers/functional/synopsis.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/headers/functional/synopsis.cc
new file mode 100644
index 000000000..a8c7231c1
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/headers/functional/synopsis.cc
@@ -0,0 +1,34 @@
+// { dg-do compile }
+
+// 2007-02-04 Benjamin Kosnik <bkoz@redhat.com>
+//
+// Copyright (C) 2007, 2009 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
+// 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 <tr1/functional>
+
+namespace std {
+namespace tr1 {
+
+ template <class T> class reference_wrapper;
+ template <class T> reference_wrapper<T> ref(T&);
+ template <class T> reference_wrapper<const T> cref(const T&);
+ template <class T> reference_wrapper<T> ref(reference_wrapper<T>);
+ template <class T> reference_wrapper<const T> cref(reference_wrapper<T>);
+
+} // namespace tr1
+} // namespace std
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/headers/memory/synopsis.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/headers/memory/synopsis.cc
new file mode 100644
index 000000000..8f859a2a9
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/headers/memory/synopsis.cc
@@ -0,0 +1,65 @@
+// { dg-do compile }
+
+// 2007-02-04 Benjamin Kosnik <bkoz@redhat.com>
+//
+// Copyright (C) 2007, 2009 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
+// 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 <tr1/memory>
+
+namespace std {
+namespace tr1 {
+
+ // [2.2.2] Class bad_weak_ptr
+ class bad_weak_ptr;
+
+ // [2.2.3] Class template shared_ptr
+ template<class T> class shared_ptr;
+
+ // [2.2.3.6] shared_ptr comparisons
+ template<class T, class U> bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b);
+ template<class T, class U> bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b);
+ template<class T, class U> bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b);
+
+ // [2.2.3.8] shared_ptr specialized algorithms
+ template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b);
+
+ // [2.2.3.9] shared_ptr casts
+ template<class T, class U> shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r);
+ template<class T, class U> shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r);
+ template<class T, class U> shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r);
+
+ // [2.2.3.7] shared_ptr I/O
+ template<class E, class T, class Y>
+ basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p);
+
+ // [2.2.3.10] shared_ptr get_deleter
+ template<class D, class T> D* get_deleter(shared_ptr<T> const& p);
+
+ // [2.2.4] Class template weak_ptr
+ template<class T> class weak_ptr;
+
+ // [2.2.4.6] weak_ptr comparison
+ template<class T, class U> bool operator<(weak_ptr<T> const& a, weak_ptr<U> const& b);
+
+ // [2.2.4.7] weak_ptr specialized algorithms
+ template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b);
+
+ // [2.2.5] Class enable_shared_from_this
+ template<class T> class enable_shared_from_this;
+} // namespace tr1
+} // namespace std
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/headers/memory/types_std_tr1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/headers/memory/types_std_tr1.cc
new file mode 100644
index 000000000..52e14917a
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/headers/memory/types_std_tr1.cc
@@ -0,0 +1,25 @@
+// { dg-do compile }
+
+// Copyright (C) 2007, 2009 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
+// 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 <tr1/memory>
+
+namespace gnu
+{
+ using std::tr1::bad_weak_ptr;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/assign.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/assign.cc
new file mode 100644
index 000000000..7e9704ec8
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/assign.cc
@@ -0,0 +1,70 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/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 reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ }
+};
+
+
+// 2.2.3.3 shared_ptr assignment [tr.util.smartptr.shared.assign]
+
+// Assignment from shared_ptr<Y>
+void
+test01()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> a;
+
+ a = std::tr1::shared_ptr<A>(new A);
+ VERIFY( a.get() != 0 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+
+ a = std::tr1::shared_ptr<A>();
+ VERIFY( a.get() == 0 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 1 );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr.cc
new file mode 100644
index 000000000..270d7ddcd
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr.cc
@@ -0,0 +1,83 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/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;
+
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+
+// 2.2.3.3 shared_ptr assignment [tr.util.smartptr.shared.assign]
+
+// Assignment from auto_ptr<Y>
+int
+test01()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> a(new A);
+ std::auto_ptr<B> b(new B);
+ a = b;
+ VERIFY( a.get() != 0 );
+ VERIFY( b.get() == 0 );
+ VERIFY( A::ctor_count == 2 );
+ VERIFY( A::dtor_count == 1 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_neg.cc
new file mode 100644
index 000000000..eb067a97b
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_neg.cc
@@ -0,0 +1,49 @@
+// { dg-do compile }
+
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+struct B { };
+
+// 2.2.3.3 shared_ptr assignment [tr.util.smartptr.shared.assign]
+
+// Assignment from incompatible auto_ptr<Y>
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> a;
+ std::auto_ptr<B> b;
+ a = b; // { dg-error "here" }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+// { dg-excess-errors "In constructor" }
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_rvalue_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_rvalue_neg.cc
new file mode 100644
index 000000000..f4d960da8
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_rvalue_neg.cc
@@ -0,0 +1,48 @@
+// { dg-do compile }
+
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+std::auto_ptr<A> source() { return std::auto_ptr<A>(); }
+
+// 2.2.3.3 shared_ptr assignment [tr.util.smartptr.shared.assign]
+
+// Assignment from rvalue auto_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> a;
+ a = source(); // { dg-error "no match" }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+// { dg-excess-errors "candidates are" }
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/dr541.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/dr541.cc
new file mode 100644
index 000000000..60a8af11b
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/dr541.cc
@@ -0,0 +1,29 @@
+// { dg-do compile }
+
+// Copyright (C) 2006, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+
+// DR 541. shared_ptr template assignment and void
+void test01()
+{
+ std::tr1::shared_ptr<void> p;
+ p.operator=<void>(p);
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr.cc
new file mode 100644
index 000000000..3faa02451
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr.cc
@@ -0,0 +1,94 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/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;
+
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+
+// 2.2.3.3 shared_ptr assignment [tr.util.smartptr.shared.assign]
+
+// Assignment from shared_ptr<Y>
+void
+test01()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> a;
+
+ a = std::tr1::shared_ptr<A>();
+ VERIFY( a.get() == 0 );
+ VERIFY( A::ctor_count == 0 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+
+ a = std::tr1::shared_ptr<A>(new A);
+ VERIFY( a.get() != 0 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+
+ a = std::tr1::shared_ptr<B>(new B);
+ VERIFY( a.get() != 0 );
+ VERIFY( A::ctor_count == 2 );
+ VERIFY( A::dtor_count == 1 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 0 );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr_neg.cc
new file mode 100644
index 000000000..490cfc4cc
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr_neg.cc
@@ -0,0 +1,51 @@
+// { dg-do compile }
+
+// Copyright (C) 2005, 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/>.
+
+// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+struct B { };
+
+// 2.2.3.3 shared_ptr assignment [tr.util.smartptr.shared.assign]
+
+// Assignment from incompatible shared_ptr<Y>
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> a;
+ std::tr1::shared_ptr<B> b;
+ a = b; // { dg-error "here" }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+// { dg-error "In member function" "" { target *-*-* } 0 }
+// { dg-error "cannot convert" "" { target *-*-* } 0 }
+// { dg-error "instantiated from" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/casts/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/casts/1.cc
new file mode 100644
index 000000000..e4d177c70
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/casts/1.cc
@@ -0,0 +1,45 @@
+// 2006-09-24 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006, 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 2.2.3.9 shared_ptr casts [tr.util.smartptr.shared.cast]
+
+#include <tr1/memory>
+#include <testsuite_tr1.h>
+
+// { dg-do compile }
+
+struct MyP { virtual ~MyP() { }; };
+struct MyDP : MyP { };
+
+int main()
+{
+ using __gnu_test::check_ret_type;
+ using std::tr1::shared_ptr;
+ using std::tr1::static_pointer_cast;
+ using std::tr1::const_pointer_cast;
+ using std::tr1::dynamic_pointer_cast;
+
+ shared_ptr<double> spd;
+ shared_ptr<const int> spci;
+ shared_ptr<MyP> spa;
+
+ check_ret_type<shared_ptr<void> >(static_pointer_cast<void>(spd));
+ check_ret_type<shared_ptr<int> >(const_pointer_cast<int>(spci));
+ check_ret_type<shared_ptr<MyDP> >(static_pointer_cast<MyDP>(spa));
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/comparison/cmp.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/comparison/cmp.cc
new file mode 100644
index 000000000..7676b45b3
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/comparison/cmp.cc
@@ -0,0 +1,82 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ virtual ~A() { }
+};
+
+struct B : A
+{
+};
+
+// 2.2.3.6 shared_ptr comparison [tr.util.smartptr.shared.cmp]
+
+int
+test01()
+{
+ // test empty shared_ptrs compare equivalent
+ std::tr1::shared_ptr<A> p1;
+ std::tr1::shared_ptr<B> p2;
+ VERIFY( p1 == p2 );
+ VERIFY( !(p1 != p2) );
+ VERIFY( !(p1 < p2) && !(p2 < p1) );
+ return 0;
+}
+
+
+// Construction from pointer
+int
+test02()
+{
+ std::tr1::shared_ptr<A> A_default;
+
+ std::tr1::shared_ptr<A> A_from_A(new A);
+ VERIFY( A_default != A_from_A );
+ VERIFY( !(A_default == A_from_A) );
+ VERIFY( (A_default < A_from_A) || (A_from_A < A_default) );
+
+ std::tr1::shared_ptr<B> B_from_B(new B);
+ VERIFY( B_from_B != A_from_A );
+ VERIFY( !(B_from_B == A_from_A) );
+ VERIFY( (B_from_B < A_from_A) || (A_from_A < B_from_B) );
+
+ A_from_A.reset();
+ VERIFY( A_default == A_from_A );
+ VERIFY( !(A_default != A_from_A) );
+ VERIFY( !(A_default < A_from_A) && !(A_from_A < A_default) );
+
+ B_from_B.reset();
+ VERIFY( B_from_B == A_from_A );
+ VERIFY( !(B_from_B != A_from_A) );
+ VERIFY( !(B_from_B < A_from_A) && !(A_from_A < B_from_B) );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/39405.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/39405.cc
new file mode 100644
index 000000000..f039ab504
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/39405.cc
@@ -0,0 +1,29 @@
+// { 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 <tr1/memory>
+
+// libstdc++/39405
+template<typename T>
+ struct foo
+ {
+ std::tr1::shared_ptr<foo<T> > m_foo;
+ };
+
+std::tr1::shared_ptr<foo<int> > t;
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc
new file mode 100644
index 000000000..0b86e8eeb
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc
@@ -0,0 +1,38 @@
+// { 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/>.
+
+// 2.2.3 Class template shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+
+// incomplete type
+struct X;
+
+std::auto_ptr<X>& ap();
+
+void test01()
+{
+ X* px = 0;
+ std::tr1::shared_ptr<X> p1(px); // { dg-error "here" }
+ // { dg-error "incomplete" "" { target *-*-* } 563 }
+
+ std::tr1::shared_ptr<X> p9(ap()); // { dg-error "here" }
+ // { dg-error "incomplete" "" { target *-*-* } 602 }
+
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr.cc
new file mode 100644
index 000000000..d916cd02d
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr.cc
@@ -0,0 +1,47 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.1 shared_ptr constructors [tr.util.smartptr.shared.const]
+
+// Construction from auto_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::auto_ptr<A> a(new A);
+ std::tr1::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/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr_neg.cc
new file mode 100644
index 000000000..1d7b921a8
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr_neg.cc
@@ -0,0 +1,47 @@
+// { dg-do compile }
+
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.3 shared_ptr assignment [tr.util.smartptr.shared.const]
+
+// Construction from const auto_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::auto_ptr<A> a;
+ std::tr1::shared_ptr<A> p(a); // { dg-error "no match" }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+// { dg-excess-errors "candidates are" }
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/copy.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/copy.cc
new file mode 100644
index 000000000..e879dd2c3
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/copy.cc
@@ -0,0 +1,134 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/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;
+ }
+};
+
+// 2.2.3.1 shared_ptr constructors [tr.util.smartptr.shared.const]
+
+// Copy construction
+int test01()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> a1;
+ std::tr1::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::tr1::shared_ptr<A> a1(new A);
+ std::tr1::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::tr1::shared_ptr<B> b(new B);
+ std::tr1::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::tr1::shared_ptr<B> b(new B, &deleter);
+ std::tr1::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/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/default.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/default.cc
new file mode 100644
index 000000000..ec68baa70
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/default.cc
@@ -0,0 +1,44 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.1 shared_ptr constructors [tr.util.smartptr.shared.const]
+
+// Default construction
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> a;
+ VERIFY( a.get() == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/pointer.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/pointer.cc
new file mode 100644
index 000000000..72f89b5b6
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/pointer.cc
@@ -0,0 +1,78 @@
+// Copyright (C) 2005, 2009, 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/>.
+
+// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+struct B : A { };
+
+
+// 2.2.3.1 shared_ptr constructors [tr.util.smartptr.shared.const]
+
+// Construction from pointer
+
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a = 0;
+ std::tr1::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::tr1::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::tr1::shared_ptr<A> p(b);
+ VERIFY( p.get() == b );
+ VERIFY( p.use_count() == 1 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr.cc
new file mode 100644
index 000000000..1429a782e
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.1 shared_ptr constructors [tr.util.smartptr.shared.const]
+
+// Construction from weak_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a = new A;
+ std::tr1::shared_ptr<A> a1(a);
+ std::tr1::weak_ptr<A> wa(a1);
+ std::tr1::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/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr_expired.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr_expired.cc
new file mode 100644
index 000000000..27fbc70dc
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr_expired.cc
@@ -0,0 +1,60 @@
+// { dg-do run { xfail *-*-* } }
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.1 shared_ptr constructors [tr.util.smartptr.shared.const]
+
+// Construction from expired weak_ptr
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> a1(new A);
+ std::tr1::weak_ptr<A> wa(a1);
+ a1.reset();
+ VERIFY( wa.expired() );
+ try
+ {
+ std::tr1::shared_ptr<A> a2(wa);
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ // Expected.
+ __throw_exception_again;
+ }
+ catch (...)
+ {
+ // Failed.
+ }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/dest/dest.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/dest/dest.cc
new file mode 100644
index 000000000..037efc587
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/dest/dest.cc
@@ -0,0 +1,132 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ ~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; }
+ ~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()(const B* p) { 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;
+ }
+};
+
+
+// 2.2.3.2 shared_ptr destructor [tr.util.smartptr.shared.dest]
+
+// empty shared_ptr
+int
+test01()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ {
+ std::tr1::shared_ptr<A> a;
+ }
+ VERIFY( A::ctor_count == 0 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+ VERIFY( D::delete_count == 0 );
+
+ return 0;
+}
+
+// shared ownership
+int
+test02()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> a;
+ {
+ a = std::tr1::shared_ptr<A>(new B, D());
+ }
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 0 );
+ VERIFY( D::delete_count == 0 );
+
+ return 0;
+}
+
+// exclusive ownership
+int
+test03()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ {
+ std::tr1::shared_ptr<A> a1(new B);
+ std::tr1::shared_ptr<A> a2(new B, D());
+ }
+ VERIFY( A::ctor_count == 2 );
+ VERIFY( A::dtor_count == 2 );
+ VERIFY( B::ctor_count == 2 );
+ VERIFY( B::dtor_count == 2 );
+ VERIFY( D::delete_count == 1 );
+
+ return 0;
+}
+
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/24595.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/24595.cc
new file mode 100644
index 000000000..d7dafb3ca
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/24595.cc
@@ -0,0 +1,38 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+using std::tr1::get_deleter;
+
+// libstdc++/24595
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<int> sp;
+ VERIFY( !get_deleter<void(*)(int*)>(sp) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/42019.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/42019.cc
new file mode 100644
index 000000000..c52aa8af6
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/42019.cc
@@ -0,0 +1,35 @@
+// { dg-options "-fno-rtti" }
+// 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/>.
+
+// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+
+// libstdc++/42019
+class A {};
+
+void test01()
+{
+ std::tr1::shared_ptr<A> spA;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/io.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/io.cc
new file mode 100644
index 000000000..e34e4c3a4
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/io.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.7 shared_ptr I/O [tr.util.smartptr.shared.io]
+
+// operator<<
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> p(new A);
+ std::ostringstream buf;
+ buf << p;
+ const std::string s = buf.str();
+ buf.str("");
+ buf << p.get();
+ VERIFY( s == buf.str() );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/swap.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/swap.cc
new file mode 100644
index 000000000..9a037d90c
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/swap.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.8 shared_ptr specialized algorithms [tr.util.smartptr.shared.spec]
+
+// std::swap
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a1 = new A;
+ A * const a2 = new A;
+ std::tr1::shared_ptr<A> p1(a1);
+ std::tr1::shared_ptr<A> p2(a2);
+ std::swap(p1, p2);
+ VERIFY( p1.get() == a2 );
+ VERIFY( p2.get() == a1 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/24805.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/24805.cc
new file mode 100644
index 000000000..ce4611c07
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/24805.cc
@@ -0,0 +1,29 @@
+// { dg-do compile }
+
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+
+// 2.2.3.4 shared_ptr modifiers [tr.util.smartptr.shared.mod]
+
+// swap
+
+// libstdc++/24805
+using std::tr1::swap;
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset.cc
new file mode 100644
index 000000000..05b0a7bd3
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset.cc
@@ -0,0 +1,87 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+struct B : A { };
+struct D
+{
+ void operator()(B* p) { delete p; ++delete_count; }
+ static long delete_count;
+};
+long D::delete_count = 0;
+
+// 2.2.3.4 shared_ptr modifiers [tr.util.smartptr.shared.mod]
+
+// reset
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a = new A;
+ std::tr1::shared_ptr<A> p1(a);
+ std::tr1::shared_ptr<A> p2(p1);
+ p1.reset();
+ VERIFY( p1.get() == 0 );
+ VERIFY( p2.get() == a );
+
+ return 0;
+}
+
+int
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a = new A;
+ B * const b = new B;
+ std::tr1::shared_ptr<A> p1(a);
+ std::tr1::shared_ptr<A> p2(p1);
+ p1.reset(b);
+ VERIFY( p1.get() == b );
+ VERIFY( p2.get() == a );
+
+ return 0;
+}
+
+int
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ {
+ std::tr1::shared_ptr<A> p1;
+ p1.reset(new B, D());
+ }
+ VERIFY( D::delete_count == 1 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset_neg.cc
new file mode 100644
index 000000000..8a8cc2286
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset_neg.cc
@@ -0,0 +1,46 @@
+// { dg-do compile }
+
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.4 shared_ptr modifiers [tr.util.smartptr.shared.mod]
+
+// reset
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::tr1::shared_ptr<A> p1(new A);
+ p1.reset(); // { dg-error "discards qualifiers" }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap.cc
new file mode 100644
index 000000000..f52b7e974
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.4 shared_ptr modifiers [tr.util.smartptr.shared.mod]
+
+// swap
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a1 = new A;
+ A * const a2 = new A;
+ std::tr1::shared_ptr<A> p1(a1);
+ std::tr1::shared_ptr<A> p2(a2);
+ p1.swap(p2);
+ VERIFY( p1.get() == a2 );
+ VERIFY( p2.get() == a1 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap_neg.cc
new file mode 100644
index 000000000..b9fa271a6
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap_neg.cc
@@ -0,0 +1,47 @@
+// { dg-do compile }
+
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.4 shared_ptr modifiers [tr.util.smartptr.shared.mod]
+
+// swap
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::tr1::shared_ptr<A> p1(new A);
+ std::tr1::shared_ptr<A> p2(new A);
+ p1.swap(p2); // { dg-error "discards qualifiers" }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/bool_conv.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/bool_conv.cc
new file mode 100644
index 000000000..ade8f4199
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/bool_conv.cc
@@ -0,0 +1,79 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.5 shared_ptr observers [tr.util.smartptr.shared.obs]
+
+// conversion to bool
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::tr1::shared_ptr<A> p1;
+ VERIFY( p1 == false );
+ const std::tr1::shared_ptr<A> p2(p1);
+ VERIFY( p2 == false );
+
+ return 0;
+}
+
+int
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> p1(new A);
+ VERIFY( p1 );
+ std::tr1::shared_ptr<A> p2(p1);
+ VERIFY( p2 );
+ p1.reset();
+ VERIFY( !p1 );
+ VERIFY( p2 );
+
+ return 0;
+}
+
+int
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> p1(new A);
+ std::tr1::shared_ptr<A> p2(p1);
+ p2.reset(new A);
+ VERIFY( p1 );
+ VERIFY( p2 );
+
+ return 0;
+}
+
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/get.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/get.cc
new file mode 100644
index 000000000..c7ad734c1
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/get.cc
@@ -0,0 +1,79 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() : i() {}
+ int i;
+};
+
+// 2.2.3.5 shared_ptr observers [tr.util.smartptr.shared.obs]
+
+// get
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a = new A;
+ const std::tr1::shared_ptr<A> p(a);
+ VERIFY( p.get() == a );
+
+ return 0;
+}
+
+// operator*
+int
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a = new A;
+ const std::tr1::shared_ptr<A> p(a);
+ VERIFY( &*p == a );
+
+ return 0;
+}
+
+
+// operator->
+int
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ A * const a = new A;
+ const std::tr1::shared_ptr<A> p(a);
+ VERIFY( &p->i == &a->i );
+
+ return 0;
+}
+
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/unique.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/unique.cc
new file mode 100644
index 000000000..a721aff49
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/unique.cc
@@ -0,0 +1,79 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 2.2.3.5 shared_ptr observers [tr.util.smartptr.shared.obs]
+
+// unique
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::tr1::shared_ptr<A> p1;
+ VERIFY( !p1.unique() );
+ const std::tr1::shared_ptr<A> p2(p1);
+ VERIFY( !p1.unique() );
+
+ return 0;
+}
+
+int
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> p1(new A);
+ VERIFY( p1.unique() );
+ std::tr1::shared_ptr<A> p2(p1);
+ VERIFY( !p1.unique() );
+ p1.reset();
+ VERIFY( !p1.unique() );
+ VERIFY( p2.unique() );
+
+ return 0;
+}
+
+int
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> p1(new A);
+ std::tr1::shared_ptr<A> p2(p1);
+ p2.reset(new A);
+ VERIFY( p1.unique() );
+ VERIFY( p2.unique() );
+
+ return 0;
+}
+
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/use_count.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/use_count.cc
new file mode 100644
index 000000000..9fcfbc98f
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/use_count.cc
@@ -0,0 +1,78 @@
+// Copyright (C) 2005, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+struct B : A { };
+
+// 2.2.3.5 shared_ptr observers [tr.util.smartptr.shared.obs]
+
+// use_count
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::tr1::shared_ptr<A> p1;
+ VERIFY( p1.use_count() == 0 );
+ const std::tr1::shared_ptr<A> p2(p1);
+ VERIFY( p1.use_count() == 0 );
+
+ return 0;
+}
+
+int
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> p1(new A);
+ std::tr1::shared_ptr<A> p2(p1);
+ p1.reset();
+ VERIFY( p1.use_count() == 0 );
+ VERIFY( p2.use_count() == 1 );
+
+ return 0;
+}
+
+int
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::shared_ptr<A> p1(new A);
+ std::tr1::shared_ptr<A> p2(p1);
+ p2.reset(new B);
+ VERIFY( p1.use_count() == 1 );
+ VERIFY( p2.use_count() == 1 );
+
+ return 0;
+}
+
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc
new file mode 100644
index 000000000..ba5d3a375
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2006, 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_tr1.h>
+
+// { dg-do compile }
+
+using namespace __gnu_test;
+using std::tr1::shared_ptr;
+template class shared_ptr<int>;
+template class shared_ptr<void>;
+template class shared_ptr<ClassType>;
+template class shared_ptr<IncompleteClass>;
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/2.cc
new file mode 100644
index 000000000..e6cf4f13f
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/2.cc
@@ -0,0 +1,33 @@
+// 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 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+#include <testsuite_tr1.h>
+
+// { dg-do compile }
+
+// Check the _S_single lock policy can be instantiated. For a thread-enabled
+// library this checks the templates can be instantiated for non-default
+// lock policy, for a single-threaded lib this is redundant but harmless.
+using namespace __gnu_test;
+using std::tr1::__shared_ptr;
+using std::tr1::_S_single;
+template class __shared_ptr<int, _S_single>;
+template class __shared_ptr<ClassType, _S_single>;
+template class __shared_ptr<IncompleteClass, _S_single>;
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc
new file mode 100644
index 000000000..31f26adcf
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc
@@ -0,0 +1,193 @@
+// Copyright (C) 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/>.
+
+// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthreads" { target *-*-solaris* } }
+
+#include <tr1/memory>
+#include <tr1/random>
+#include <vector>
+#include <testsuite_hooks.h>
+#include <iostream>
+#include <cstdlib>
+
+#include <pthread.h>
+
+#ifdef _GLIBCXX_HAVE_UNISTD_H
+#include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING
+#endif
+
+/* This (brute-force) tests the atomicity and thus thread safety of the
+ * shared_ptr <- weak_ptr
+ * assignment operation by allocating a test object, retrieving a weak
+ * reference to it, and letting a number of threads repeatedly create strong
+ * references from the weak reference.
+ * Specifically, this tests the function _Sp_counted_base<true>::add_ref_lock()
+ */
+
+
+const unsigned int HAMMER_MAX_THREADS = 10;
+const unsigned int POOL_SIZE = 1000;
+const unsigned long HAMMER_REPEAT = 100000;
+const unsigned long KILL_ONE_IN = 1000;
+
+struct A
+ {
+ static _Atomic_word counter;
+ A()
+ {
+ __gnu_cxx::__atomic_add(&counter, 1);
+ }
+ ~A()
+ {
+ __gnu_cxx::__atomic_add(&counter, -1);
+ }
+ };
+
+_Atomic_word A::counter = 0;
+
+typedef std::tr1::shared_ptr<A> sp_A_t;
+typedef std::tr1::weak_ptr<A> wp_A_t;
+
+typedef std::vector<sp_A_t> sp_vector_t;
+typedef std::vector<wp_A_t> wp_vector_t;
+
+struct shared_and_weak_pools
+{
+ sp_vector_t& shared_pool;
+ wp_vector_t& weak_pool;
+
+ shared_and_weak_pools(sp_vector_t& _shared_pool, wp_vector_t& _weak_pool)
+ : shared_pool(_shared_pool), weak_pool(_weak_pool)
+ { }
+};
+
+void* thread_hammer_and_kill(void* opaque_pools)
+{
+ shared_and_weak_pools& pools = *static_cast<shared_and_weak_pools*>(opaque_pools);
+ // Using the same parameters as in the RNG test cases.
+ std::tr1::mersenne_twister<
+ unsigned long, 32, 624, 397, 31,
+ 0x9908b0dful, 11, 7,
+ 0x9d2c5680ul, 15,
+ 0xefc60000ul, 18> rng;
+
+ sp_vector_t::iterator cur_shared = pools.shared_pool.begin();
+ wp_vector_t::iterator cur_weak = pools.weak_pool.begin();
+
+ for (unsigned int i = 0; i < HAMMER_REPEAT; ++i)
+ {
+ try
+ {
+ sp_A_t strong(*cur_weak);
+ }
+ catch (std::tr1::bad_weak_ptr& exception)
+ {
+ ++cur_weak;
+ if (cur_weak == pools.weak_pool.end())
+ break;
+ }
+
+ if (rng() % KILL_ONE_IN == 0)
+ {
+ cur_shared->reset();
+ ++cur_shared;
+ }
+ }
+ return 0;
+}
+
+void* thread_hammer(void* opaque_weak)
+{
+ wp_vector_t& weak_pool = *static_cast<wp_vector_t*>(opaque_weak);
+ // Using the same parameters as in the RNG test cases.
+ std::tr1::mersenne_twister<
+ unsigned long, 32, 624, 397, 31,
+ 0x9908b0dful, 11, 7,
+ 0x9d2c5680ul, 15,
+ 0xefc60000ul, 18> rng;
+ wp_vector_t::iterator cur_weak = weak_pool.begin();
+
+ for (unsigned int i = 0; i < HAMMER_REPEAT; ++i)
+ {
+ try
+ {
+ sp_A_t strong(*cur_weak);
+ }
+ catch (std::tr1::bad_weak_ptr& exception)
+ {
+ ++cur_weak;
+ if (cur_weak == weak_pool.end())
+ break;
+ }
+ }
+ return 0;
+}
+
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ sp_vector_t obj_pool(POOL_SIZE);
+
+ for(sp_vector_t::iterator cur = obj_pool.begin(); cur != obj_pool.end(); ++cur)
+ {
+ cur->reset(new A);
+ }
+ // Obtain weak references.
+ std::vector<wp_vector_t> weak_pool(HAMMER_MAX_THREADS, wp_vector_t(obj_pool.begin(), obj_pool.end()));
+
+ // Launch threads with pointer to weak reference.
+ pthread_t threads[HAMMER_MAX_THREADS];
+#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
+ pthread_setconcurrency (HAMMER_MAX_THREADS);
+#endif
+
+ pthread_attr_t tattr;
+ pthread_attr_init(&tattr);
+
+ shared_and_weak_pools pools(obj_pool, weak_pool[0]);
+ pthread_create(threads, &tattr, thread_hammer_and_kill, static_cast<void*>(&pools));
+ for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++)
+ {
+ if (pthread_create(&threads[worker], &tattr,
+ thread_hammer, static_cast<void*>(&weak_pool[worker])))
+ std::abort();
+ }
+ // Wait for threads to complete, then check integrity of reference.
+ void* status;
+ for (unsigned int worker = 0; worker < HAMMER_MAX_THREADS; worker++)
+ {
+ if (pthread_join(threads[worker], &status))
+ std::abort();
+ }
+ obj_pool.clear();
+
+ VERIFY( A::counter == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc
new file mode 100644
index 000000000..6b94d04b6
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc
@@ -0,0 +1,195 @@
+// Copyright (C) 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/>.
+
+// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthreads" { target *-*-solaris* } }
+
+#include <tr1/memory>
+#include <tr1/random>
+#include <vector>
+#include <testsuite_hooks.h>
+#include <iostream>
+#include <cstdlib>
+
+#include <pthread.h>
+
+#ifdef _GLIBCXX_HAVE_UNISTD_H
+#include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING
+#endif
+
+/* This (brute-force) tests the atomicity and thus thread safety of the
+ * shared_ptr <- weak_ptr
+ * assignment operation by allocating a test object, retrieving a weak
+ * reference to it, and letting a number of threads repeatedly create strong
+ * references from the weak reference.
+ * Specifically, this tests the function _Sp_counted_base<true>::add_ref_lock()
+ */
+
+
+const unsigned int HAMMER_MAX_THREADS = 10;
+const unsigned int POOL_SIZE = 1000;
+const unsigned long HAMMER_REPEAT = 100000;
+const unsigned long KILL_ONE_IN = 1000;
+
+struct A
+ {
+ static _Atomic_word counter;
+ A()
+ {
+ __gnu_cxx::__atomic_add(&counter, 1);
+ }
+ ~A()
+ {
+ __gnu_cxx::__atomic_add(&counter, -1);
+ }
+ };
+
+_Atomic_word A::counter = 0;
+
+using std::tr1::_S_mutex;
+
+typedef std::tr1::__shared_ptr<A, _S_mutex> sp_A_t;
+typedef std::tr1::__weak_ptr<A, _S_mutex> wp_A_t;
+
+typedef std::vector<sp_A_t> sp_vector_t;
+typedef std::vector<wp_A_t> wp_vector_t;
+
+struct shared_and_weak_pools
+{
+ sp_vector_t& shared_pool;
+ wp_vector_t& weak_pool;
+
+ shared_and_weak_pools(sp_vector_t& _shared_pool, wp_vector_t& _weak_pool)
+ : shared_pool(_shared_pool), weak_pool(_weak_pool)
+ { }
+};
+
+void* thread_hammer_and_kill(void* opaque_pools)
+{
+ shared_and_weak_pools& pools = *static_cast<shared_and_weak_pools*>(opaque_pools);
+ // Using the same parameters as in the RNG test cases.
+ std::tr1::mersenne_twister<
+ unsigned long, 32, 624, 397, 31,
+ 0x9908b0dful, 11, 7,
+ 0x9d2c5680ul, 15,
+ 0xefc60000ul, 18> rng;
+
+ sp_vector_t::iterator cur_shared = pools.shared_pool.begin();
+ wp_vector_t::iterator cur_weak = pools.weak_pool.begin();
+
+ for (unsigned int i = 0; i < HAMMER_REPEAT; ++i)
+ {
+ try
+ {
+ sp_A_t strong(*cur_weak);
+ }
+ catch (std::tr1::bad_weak_ptr& exception)
+ {
+ ++cur_weak;
+ if (cur_weak == pools.weak_pool.end())
+ break;
+ }
+
+ if (rng() % KILL_ONE_IN == 0)
+ {
+ cur_shared->reset();
+ ++cur_shared;
+ }
+ }
+ return 0;
+}
+
+void* thread_hammer(void* opaque_weak)
+{
+ wp_vector_t& weak_pool = *static_cast<wp_vector_t*>(opaque_weak);
+ // Using the same parameters as in the RNG test cases.
+ std::tr1::mersenne_twister<
+ unsigned long, 32, 624, 397, 31,
+ 0x9908b0dful, 11, 7,
+ 0x9d2c5680ul, 15,
+ 0xefc60000ul, 18> rng;
+ wp_vector_t::iterator cur_weak = weak_pool.begin();
+
+ for (unsigned int i = 0; i < HAMMER_REPEAT; ++i)
+ {
+ try
+ {
+ sp_A_t strong(*cur_weak);
+ }
+ catch (std::tr1::bad_weak_ptr& exception)
+ {
+ ++cur_weak;
+ if (cur_weak == weak_pool.end())
+ break;
+ }
+ }
+ return 0;
+}
+
+int
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ sp_vector_t obj_pool(POOL_SIZE);
+
+ for(sp_vector_t::iterator cur = obj_pool.begin(); cur != obj_pool.end(); ++cur)
+ {
+ cur->reset(new A);
+ }
+ // Obtain weak references.
+ std::vector<wp_vector_t> weak_pool(HAMMER_MAX_THREADS, wp_vector_t(obj_pool.begin(), obj_pool.end()));
+
+ // Launch threads with pointer to weak reference.
+ pthread_t threads[HAMMER_MAX_THREADS];
+#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
+ pthread_setconcurrency (HAMMER_MAX_THREADS);
+#endif
+
+ pthread_attr_t tattr;
+ pthread_attr_init(&tattr);
+
+ shared_and_weak_pools pools(obj_pool, weak_pool[0]);
+ pthread_create(threads, &tattr, thread_hammer_and_kill, static_cast<void*>(&pools));
+ for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++)
+ {
+ if (pthread_create(&threads[worker], &tattr,
+ thread_hammer, static_cast<void*>(&weak_pool[worker])))
+ std::abort();
+ }
+ // Wait for threads to complete, then check integrity of reference.
+ void* status;
+ for (unsigned int worker = 0; worker < HAMMER_MAX_THREADS; worker++)
+ {
+ if (pthread_join(threads[worker], &status))
+ std::abort();
+ }
+ obj_pool.clear();
+
+ VERIFY( A::counter == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/lock/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/lock/1.cc
new file mode 100644
index 000000000..a64eafbb2
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/lock/1.cc
@@ -0,0 +1,35 @@
+// 2006-09-24 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006, 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 2.2.4 Template class weak_ptr [tr.util.smartptr.weak]
+
+#include <tr1/memory>
+#include <testsuite_tr1.h>
+
+// { dg-do compile }
+
+int main()
+{
+ using __gnu_test::check_ret_type;
+ using std::tr1::weak_ptr;
+ using std::tr1::shared_ptr;
+
+ weak_ptr<int> wp;
+ check_ret_type<shared_ptr<int> >(wp.lock());
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc
new file mode 100644
index 000000000..a533850ec
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2006, 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 2.2.4 Template class weak_ptr [tr.util.smartptr.weak]
+
+#include <tr1/memory>
+#include <testsuite_tr1.h>
+
+// { dg-do compile }
+
+using namespace __gnu_test;
+using std::tr1::weak_ptr;
+template class weak_ptr<int>;
+template class weak_ptr<void>;
+template class weak_ptr<ClassType>;
+template class weak_ptr<IncompleteClass>;
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/2.cc
new file mode 100644
index 000000000..57fbda8b6
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/2.cc
@@ -0,0 +1,34 @@
+// 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 2.2.4 Template class weak_ptr [tr.util.smartptr.weak]
+
+#include <tr1/memory>
+#include <testsuite_tr1.h>
+
+// { dg-do compile }
+
+// Check the _S_single lock policy can be instantiated. For a thread-enabled
+// library this checks the templates can be instantiated for non-default
+// lock policy, for a single-threaded lib this is redundant but harmless.
+using namespace __gnu_test;
+using std::tr1::__weak_ptr;
+using std::tr1::_S_single;
+template class __weak_ptr<int, _S_single>;
+template class __weak_ptr<void, _S_single>;
+template class __weak_ptr<ClassType, _S_single>;
+template class __weak_ptr<IncompleteClass, _S_single>;