summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorJonathan Wakely <redi@gcc.gnu.org>2005-02-22 00:10:22 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2005-02-22 00:10:22 +0000
commit7dfded9114ec3aad2f2eafe5ff606215c602620b (patch)
tree6f90dfb69e7c10ef5b3f9e81389168eef9327e59 /libstdc++-v3/testsuite
parent11996a3c452935418437898cc5131e41097736e4 (diff)
downloadgcc-7dfded9114ec3aad2f2eafe5ff606215c602620b.tar.gz
memory: New file.
* include/tr1/memory: New file. * include/Makefile.am, include/Makefile.in: Add new TR1 header. * testsuite/tr1/2_general_utilities/memory/ enable_shared_from_this/not_shared.cc: New test. * testsuite/tr1/2_general_utilities/memory/ enable_shared_from_this/not_shared2.cc: New test. * testsuite/tr1/2_general_utilities/memory/ enable_shared_from_this/not_shared3.cc: New test. * testsuite/tr1/2_general_utilities/memory/ enable_shared_from_this/shared.cc: New test. * testsuite/tr1/2_general_utilities/memory/ enable_shared_from_this/still_shared.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/assign/assign.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/assign/auto_ptr.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/assign/auto_ptr_neg.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/assign/auto_ptr_rvalue_neg.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/assign/shared_ptr.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/assign/shared_ptr_neg.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/comparison/cmp.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/cons/auto_ptr.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/cons/auto_ptr_neg.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/cons/copy.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/cons/default.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/cons/pointer.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/cons/weak_ptr.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/cons/weak_ptr_expired.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/dest/dest.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/misc/io.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/misc/swap.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/modifiers/reset.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/modifiers/reset_neg.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/modifiers/swap.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/modifiers/swap_neg.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/observers/bool_conv.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/observers/get.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/observers/unique.cc: New test. * testsuite/tr1/2_general_utilities/memory/ shared_ptr/observers/use_count.cc: New test. From-SVN: r95361
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared.cc56
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared2.cc55
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared3.cc57
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/shared.cc46
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/still_shared.cc55
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/assign.cc71
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr.cc84
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_neg.cc50
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_rvalue_neg.cc48
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr.cc95
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr_neg.cc49
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/comparison/cmp.cc83
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr.cc48
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr_neg.cc48
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/copy.cc135
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/default.cc45
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/pointer.cc79
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr.cc50
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr_expired.cc60
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/dest/dest.cc133
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/io.cc51
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/swap.cc50
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset.cc88
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset_neg.cc45
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap.cc50
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap_neg.cc46
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/bool_conv.cc80
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/get.cc80
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/unique.cc80
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/use_count.cc79
30 files changed, 1996 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared.cc
new file mode 100644
index 00000000000..493bd84a77c
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared.cc
@@ -0,0 +1,56 @@
+// { dg-do run { xfail *-*-* } }
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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();
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ __throw_exception_again;
+ }
+ catch (...)
+ {
+ }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared2.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared2.cc
new file mode 100644
index 00000000000..a6ca74da389
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared2.cc
@@ -0,0 +1,55 @@
+// { dg-do run { xfail *-*-* } }
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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();
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ __throw_exception_again;
+ }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared3.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared3.cc
new file mode 100644
index 00000000000..3bca336bc20
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared3.cc
@@ -0,0 +1,57 @@
+// { dg-do run { xfail *-*-* } }
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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();
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ __throw_exception_again;
+ }
+
+ return 0;
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/shared.cc
new file mode 100644
index 00000000000..aba0c5fb32f
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/shared.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/enable_shared_from_this/still_shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/still_shared.cc
new file mode 100644
index 00000000000..8c3c53fad51
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/still_shared.cc
@@ -0,0 +1,55 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/assign/assign.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/assign.cc
new file mode 100644
index 00000000000..a2c5dd4cf11
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/assign.cc
@@ -0,0 +1,71 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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>
+int
+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/memory/shared_ptr/assign/auto_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr.cc
new file mode 100644
index 00000000000..85c5c899409
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/assign/auto_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_neg.cc
new file mode 100644
index 00000000000..dd186135cd0
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_neg.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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-error "In constructor" "" { target *-*-* } 0 }
+// { dg-error "cannot convert" "" { target *-*-* } 0 }
+// { dg-error "instantiated from" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_rvalue_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_rvalue_neg.cc
new file mode 100644
index 00000000000..38a6efabce5
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_rvalue_neg.cc
@@ -0,0 +1,48 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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-error "auto_ptr" "" { target *-*-* } 0 }
+// { dg-error "shared_ptr" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr.cc
new file mode 100644
index 00000000000..a159156fa9d
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr.cc
@@ -0,0 +1,95 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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>
+int
+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/memory/shared_ptr/assign/shared_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr_neg.cc
new file mode 100644
index 00000000000..79776fc66f1
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr_neg.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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 }
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/comparison/cmp.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/comparison/cmp.cc
new file mode 100644
index 00000000000..9201d4094d8
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/comparison/cmp.cc
@@ -0,0 +1,83 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/cons/auto_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr.cc
new file mode 100644
index 00000000000..796ae089621
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr.cc
@@ -0,0 +1,48 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/cons/auto_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr_neg.cc
new file mode 100644
index 00000000000..a43e9122e44
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr_neg.cc
@@ -0,0 +1,48 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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-error "shared_ptr" "candidates are" { target *-*-* } 499 }
+
+// { dg-error "shared_ptr" "" { target *-*-* } 489 }
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/copy.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/copy.cc
new file mode 100644
index 00000000000..aa0daa2e80c
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/copy.cc
@@ -0,0 +1,135 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/cons/default.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/default.cc
new file mode 100644
index 00000000000..7258e2edb75
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/default.cc
@@ -0,0 +1,45 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/cons/pointer.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/pointer.cc
new file mode 100644
index 00000000000..67687823489
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/pointer.cc
@@ -0,0 +1,79 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr.cc
new file mode 100644
index 00000000000..02441623d05
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/cons/weak_ptr_expired.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr_expired.cc
new file mode 100644
index 00000000000..8b0213ec726
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr_expired.cc
@@ -0,0 +1,60 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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();
+ try
+ {
+ std::tr1::shared_ptr<A> a2(wa);
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ // Expected.
+ }
+ catch (...)
+ {
+ // Failed.
+ __throw_exception_again;
+ }
+ VERIFY( wa.expired() );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/dest/dest.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/dest/dest.cc
new file mode 100644
index 00000000000..081d2dac683
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/dest/dest.cc
@@ -0,0 +1,133 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/misc/io.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/io.cc
new file mode 100644
index 00000000000..17e836feef2
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/io.cc
@@ -0,0 +1,51 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/misc/swap.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/swap.cc
new file mode 100644
index 00000000000..930c2b9a6be
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/swap.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/modifiers/reset.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset.cc
new file mode 100644
index 00000000000..6976cc7d233
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset.cc
@@ -0,0 +1,88 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/modifiers/reset_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset_neg.cc
new file mode 100644
index 00000000000..623e07ab98d
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset_neg.cc
@@ -0,0 +1,45 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/modifiers/swap.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap.cc
new file mode 100644
index 00000000000..15d17d4308c
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/modifiers/swap_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap_neg.cc
new file mode 100644
index 00000000000..c16e2262724
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap_neg.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/observers/bool_conv.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/bool_conv.cc
new file mode 100644
index 00000000000..f091e591c39
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/bool_conv.cc
@@ -0,0 +1,80 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/observers/get.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/get.cc
new file mode 100644
index 00000000000..7a0a6e521f6
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/get.cc
@@ -0,0 +1,80 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/observers/unique.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/unique.cc
new file mode 100644
index 00000000000..f01121273da
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/unique.cc
@@ -0,0 +1,80 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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/memory/shared_ptr/observers/use_count.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/use_count.cc
new file mode 100644
index 00000000000..9338dec3acb
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/use_count.cc
@@ -0,0 +1,79 @@
+// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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;
+}