+2007-02-20 Benjamin Kosnik <bkoz@redhat.com>
+
+ Directory layout flattening.
+
+ Added in testsuite:
+ * 20_util/allocator
+ * 20_util/auto_ptr
+ * 20_util/function_objects
+ * 20_util/function_objects/binders
+ * 20_util/function_objects/binders/1.cc
+ * 20_util/function_objects/binders/3113.cc
+ * 20_util/function_objects/comparisons.cc
+ * 20_util/pair
+ * 20_util/raw_storage_iterator
+ * 20_util/rel_ops.cc
+ * 20_util/specialized_algorithms
+ * 20_util/specialized_algorithms/16505.cc
+ * 20_util/temporary_buffer.cc
+ * 26_numerics/numeric_arrays/slice_array
+ * 26_numerics/numeric_arrays/slice_array/array_assignment.cc
+ * 26_numerics/numeric_arrays/slice_array/requirements
+ * 26_numerics/numeric_arrays/slice_array/requirements/
+ explicit_instantiation.cc
+ * 26_numerics/numeric_arrays/slice_array/requirements/typedefs.cc
+ * 26_numerics/numeric_arrays/valarray
+ * 26_numerics/numeric_arrays/valarray/27867.cc
+ * 26_numerics/numeric_arrays/valarray/28277.cc
+ * 26_numerics/numeric_arrays/valarray/30416.cc
+ * 26_numerics/numeric_arrays/valarray/algo.cc
+ * 26_numerics/numeric_arrays/valarray/binary_closure.cc
+ * 26_numerics/numeric_arrays/valarray/const_bracket.cc
+ * 26_numerics/numeric_arrays/valarray/dr543.cc
+ * 26_numerics/numeric_arrays/valarray/name_lookup.cc
+ * 26_numerics/numeric_arrays/valarray/operators.cc
+ * 26_numerics/numeric_arrays/valarray/requirements
+ * 26_numerics/numeric_arrays/valarray/requirements/
+ explicit_instantiation.cc
+ * 26_numerics/numeric_arrays/valarray/requirements/typedefs.cc
+ * 26_numerics/numeric_arrays/valarray/subset_assignment.cc
+ * tr1/2_general_utilities/enable_shared_from_this
+ * tr1/2_general_utilities/shared_ptr
+ * tr1/2_general_utilities/weak_ptr
+
+ Deleted in testsuite:
+ * 20_util/functional
+ * 20_util/functional/binders
+ * 20_util/functional/binders/1.cc
+ * 20_util/functional/binders/3113.cc
+ * 20_util/functional/comparisons.cc
+ * 20_util/memory
+ * 20_util/memory/16505.cc
+ * 20_util/memory/allocator
+ * 20_util/memory/allocator/10378.cc
+ * 20_util/memory/allocator/14176.cc
+ * 20_util/memory/allocator/1.cc
+ * 20_util/memory/allocator/8230.cc
+ * 20_util/memory/allocator/requirements
+ * 20_util/memory/allocator/requirements/explicit_instantiation
+ * 20_util/memory/allocator/requirements/explicit_instantiation/1.cc
+ * 20_util/memory/auto_ptr
+ * 20_util/memory/auto_ptr/1.cc
+ * 20_util/memory/auto_ptr/2.cc
+ * 20_util/memory/auto_ptr/3946.cc
+ * 20_util/memory/auto_ptr/3.cc
+ * 20_util/memory/auto_ptr/4.cc
+ * 20_util/memory/auto_ptr/5.cc
+ * 20_util/memory/auto_ptr/6.cc
+ * 20_util/memory/auto_ptr/7.cc
+ * 20_util/memory/auto_ptr/assign_neg.cc
+ * 20_util/memory/auto_ptr/requirements
+ * 20_util/memory/auto_ptr/requirements/explicit_instantiation
+ * 20_util/memory/auto_ptr/requirements/explicit_instantiation/1.cc
+ * 20_util/memory/raw_storage_iterator
+ * 20_util/memory/raw_storage_iterator/requirements
+ * 20_util/memory/raw_storage_iterator/requirements/base_classes.cc
+ * 20_util/memory/raw_storage_iterator/requirements/
+ explicit_instantiation
+ * 20_util/memory/raw_storage_iterator/requirements/
+ explicit_instantiation/1.cc
+ * 20_util/memory/raw_storage_iterator/requirements/typedefs.cc
+ * 20_util/memory/temporary_buffer.cc
+ * 20_util/utility
+ * 20_util/utility/pair
+ * 20_util/utility/pair/1.cc
+ * 20_util/utility/pair/2.cc
+ * 20_util/utility/pair/3.cc
+ * 20_util/utility/pair/4.cc
+ * 20_util/utility/pair/requirements
+ * 20_util/utility/pair/requirements/explicit_instantiation
+ * 20_util/utility/pair/requirements/explicit_instantiation/1.cc
+ * 20_util/utility/rel_ops.cc
+ * 26_numerics/numeric_arrays/27867.cc
+ * 26_numerics/numeric_arrays/28277.cc
+ * 26_numerics/numeric_arrays/30416.cc
+ * 26_numerics/numeric_arrays/binary_closure.cc
+ * 26_numerics/numeric_arrays/dr543.cc
+ * 26_numerics/numeric_arrays/slice_array_assignment.cc
+ * 26_numerics/numeric_arrays/valarray.cc
+ * 26_numerics/numeric_arrays/valarray_const_bracket.cc
+ * 26_numerics/numeric_arrays/valarray_name_lookup.cc
+ * 26_numerics/numeric_arrays/valarray_operators.cc
+ * 26_numerics/numeric_arrays/valarray_subset_assignment.cc
+ * tr1/2_general_utilities/memory
+ * tr1/2_general_utilities/memory/enable_shared_from_this
+ * tr1/2_general_utilities/memory/enable_shared_from_this/1.cc
+ * tr1/2_general_utilities/memory/enable_shared_from_this/not_shared2.cc
+ * tr1/2_general_utilities/memory/enable_shared_from_this/not_shared3.cc
+ * tr1/2_general_utilities/memory/enable_shared_from_this/not_shared.cc
+ * tr1/2_general_utilities/memory/enable_shared_from_this/requirements
+ * tr1/2_general_utilities/memory/enable_shared_from_this/
+ requirements/explicit_instantiation
+ * tr1/2_general_utilities/memory/enable_shared_from_this/
+ requirements/explicit_instantiation/1.cc
+ * tr1/2_general_utilities/memory/enable_shared_from_this/shared.cc
+ * tr1/2_general_utilities/memory/enable_shared_from_this/
+ still_shared.cc
+ * tr1/2_general_utilities/memory/shared_ptr
+ * tr1/2_general_utilities/memory/shared_ptr/assign
+ * tr1/2_general_utilities/memory/shared_ptr/assign/assign.cc
+ * tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr.cc
+ * tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_neg.cc
+ * tr1/2_general_utilities/memory/shared_ptr/assign/
+ auto_ptr_rvalue_neg.cc
+ * tr1/2_general_utilities/memory/shared_ptr/assign/dr541.cc
+ * tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr.cc
+ * tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr_neg.cc
+ * tr1/2_general_utilities/memory/shared_ptr/casts
+ * tr1/2_general_utilities/memory/shared_ptr/casts/1.cc
+ * tr1/2_general_utilities/memory/shared_ptr/comparison
+ * tr1/2_general_utilities/memory/shared_ptr/comparison/cmp.cc
+ * tr1/2_general_utilities/memory/shared_ptr/cons
+ * tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr.cc
+ * tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr_neg.cc
+ * tr1/2_general_utilities/memory/shared_ptr/cons/copy.cc
+ * tr1/2_general_utilities/memory/shared_ptr/cons/default.cc
+ * tr1/2_general_utilities/memory/shared_ptr/cons/pointer.cc
+ * tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr.cc
+ * tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr_expired.cc
+ * tr1/2_general_utilities/memory/shared_ptr/dest
+ * tr1/2_general_utilities/memory/shared_ptr/dest/dest.cc
+ * tr1/2_general_utilities/memory/shared_ptr/misc
+ * tr1/2_general_utilities/memory/shared_ptr/misc/24595.cc
+ * tr1/2_general_utilities/memory/shared_ptr/misc/io.cc
+ * tr1/2_general_utilities/memory/shared_ptr/misc/swap.cc
+ * tr1/2_general_utilities/memory/shared_ptr/modifiers
+ * tr1/2_general_utilities/memory/shared_ptr/modifiers/24805.cc
+ * tr1/2_general_utilities/memory/shared_ptr/modifiers/reset.cc
+ * tr1/2_general_utilities/memory/shared_ptr/modifiers/reset_neg.cc
+ * tr1/2_general_utilities/memory/shared_ptr/modifiers/swap.cc
+ * tr1/2_general_utilities/memory/shared_ptr/modifiers/swap_neg.cc
+ * tr1/2_general_utilities/memory/shared_ptr/observers
+ * tr1/2_general_utilities/memory/shared_ptr/observers/bool_conv.cc
+ * tr1/2_general_utilities/memory/shared_ptr/observers/get.cc
+ * tr1/2_general_utilities/memory/shared_ptr/observers/unique.cc
+ * tr1/2_general_utilities/memory/shared_ptr/observers/use_count.cc
+ * tr1/2_general_utilities/memory/shared_ptr/requirements
+ * tr1/2_general_utilities/memory/shared_ptr/requirements/
+ explicit_instantiation
+ * tr1/2_general_utilities/memory/shared_ptr/requirements/
+ explicit_instantiation/1.cc
+ * tr1/2_general_utilities/memory/shared_ptr/thread
+ * tr1/2_general_utilities/memory/shared_ptr/thread/
+ default_weaktoshared.cc
+ * tr1/2_general_utilities/memory/shared_ptr/thread/
+ mutex_weaktoshared.cc
+ * tr1/2_general_utilities/memory/weak_ptr
+ * tr1/2_general_utilities/memory/weak_ptr/lock
+ * tr1/2_general_utilities/memory/weak_ptr/lock/1.cc
+ * tr1/2_general_utilities/memory/weak_ptr/requirements
+ * tr1/2_general_utilities/memory/weak_ptr/requirements/
+ explicit_instantiation
+ * tr1/2_general_utilities/memory/weak_ptr/requirements/
+ explicit_instantiation/1.cc
+
2007-02-20 Benjamin Kosnik <bkoz@redhat.com>
Revamp library API testing.
- Added:
+
+ Added in testsuite:
* 17_intro/headers
* 17_intro/headers/all_assert_neg.cc
* 17_intro/headers/all_c++200x_compatibility.cc
* tr1/6_containers/unordered_set/swap/2.cc
* tr1/using_namespace_std_tr1.cc
- Deleted:
+ Deleted in testsuite:
* 17_intro/header_cassert.cc
* 17_intro/header_cerrno.cc
* 17_intro/header_csetjmp.cc
* tr1/6_containers/unordered/types/multiset_iterator.cc
* tr1/6_containers/unordered/types/set_iterator.cc
- * 24_iterators/reverse_iterator/2.cc: To just one
+ * testsuite/24_iterators/reverse_iterator/2.cc: To just one
non-requirements test.
- * ext/headers.cc: Add new includes.
+ * testsuite/ext/headers.cc: Add new includes.
2007-02-18 Paolo Carlini <pcarlini@suse.de>
--- /dev/null
+// 2001-06-14 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.1.1 allocator members
+
+#include <memory>
+#include <stdexcept>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+struct gnu { };
+
+bool check_new = false;
+bool check_delete = false;
+
+void*
+operator new(std::size_t n) throw(std::bad_alloc)
+{
+ check_new = true;
+ return std::malloc(n);
+}
+
+void operator delete(void *v) throw()
+{
+ check_delete = true;
+ return std::free(v);
+}
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::allocator<gnu> obj;
+
+ // NB: These should work for various size allocation and
+ // deallocations. Currently, they only work as expected for sizes >
+ // _MAX_BYTES as defined in stl_alloc.h, which happes to be 128.
+ gnu* pobj = obj.allocate(256);
+ VERIFY( check_new );
+
+ obj.deallocate(pobj, 256);
+ VERIFY( check_delete );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
--- /dev/null
+// Copyright (C) 2003, 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.1.5 allocator requirements / 20.4.1.1 allocator members
+
+#include <list>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+class Bob
+{
+public:
+ static void* operator new(size_t sz)
+ { return std::malloc(sz); }
+};
+
+// libstdc++/10378
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ list<Bob> uniset;
+ uniset.push_back(Bob());
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.1.1 allocator members
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+// libstdc++/14176
+void test02()
+{
+ unsigned int len = 0;
+ std::allocator<int> a;
+ int* p = a.allocate(len);
+ a.deallocate(p, len);
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 2001-06-14 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.1.1 allocator members
+
+#include <memory>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+// libstdc++/8230
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ try
+ {
+ std::allocator<int> alloc;
+ const std::allocator<int>::size_type n = alloc.max_size();
+ int* p = alloc.allocate(n + 1);
+ p[n] = 2002;
+ }
+ catch(const std::bad_alloc& e)
+ {
+ // Allowed.
+ test = true;
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers.
+
+#include <memory>
+
+template class std::allocator<int>;
--- /dev/null
+// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.5 Template class auto_ptr [lib.auto.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ virtual ~A() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long A::ctor_count = 0;
+long A::dtor_count = 0;
+
+struct B : A
+{
+ B() { ++ctor_count; }
+ virtual ~B() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long B::ctor_count = 0;
+long B::dtor_count = 0;
+
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+
+// 20.4.5.1 auto_ptr constructors [lib.auto.ptr.cons]
+
+// Construction from pointer
+int
+test01()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::auto_ptr<A> A_default;
+ VERIFY( A_default.get() == 0 );
+ VERIFY( A::ctor_count == 0 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+
+ std::auto_ptr<A> A_from_A(new A);
+ VERIFY( A_from_A.get() != 0 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+
+ std::auto_ptr<A> A_from_B(new B);
+ VERIFY( A_from_B.get() != 0 );
+ VERIFY( A::ctor_count == 2 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.5 Template class auto_ptr [lib.auto.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ virtual ~A() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long A::ctor_count = 0;
+long A::dtor_count = 0;
+
+struct B : A
+{
+ B() { ++ctor_count; }
+ virtual ~B() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long B::ctor_count = 0;
+long B::dtor_count = 0;
+
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+// Construction from std::auto_ptr
+int
+test02()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::auto_ptr<A> A_from_A(new A);
+ std::auto_ptr<B> B_from_B(new B);
+
+ std::auto_ptr<A> A_from_ptr_A(A_from_A);
+ std::auto_ptr<A> A_from_ptr_B(B_from_B);
+ VERIFY( A_from_A.get() == 0 );
+ VERIFY( B_from_B.get() == 0 );
+ VERIFY( A_from_ptr_A.get() != 0 );
+ VERIFY( A_from_ptr_B.get() != 0 );
+ VERIFY( A::ctor_count == 2 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.5 Template class auto_ptr [lib.auto.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ virtual ~A() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long A::ctor_count = 0;
+long A::dtor_count = 0;
+
+struct B : A
+{
+ B() { ++ctor_count; }
+ virtual ~B() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long B::ctor_count = 0;
+long B::dtor_count = 0;
+
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+// Assignment from std::auto_ptr
+int
+test03()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::auto_ptr<A> A_from_ptr_A;
+ std::auto_ptr<A> A_from_ptr_B;
+ std::auto_ptr<A> A_from_A(new A);
+ std::auto_ptr<B> B_from_B(new B);
+
+ A_from_ptr_A = A_from_A;
+ A_from_ptr_B = B_from_B;
+ VERIFY( A_from_A.get() == 0 );
+ VERIFY( B_from_B.get() == 0 );
+ VERIFY( A_from_ptr_A.get() != 0 );
+ VERIFY( A_from_ptr_B.get() != 0 );
+ VERIFY( A::ctor_count == 2 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.5 Template class auto_ptr [lib.auto.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+// libstdc++/3946
+// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html
+struct Base { };
+struct Derived : public Base { };
+
+std::auto_ptr<Derived>
+conversiontest08() { return std::auto_ptr<Derived>(new Derived); }
+
+void
+test08()
+{
+ std::auto_ptr<Base> ptr;
+ ptr = conversiontest08();
+}
+
+
+int
+main()
+{
+ test08();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.5 Template class auto_ptr [lib.auto.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ virtual ~A() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long A::ctor_count = 0;
+long A::dtor_count = 0;
+
+struct B : A
+{
+ B() { ++ctor_count; }
+ virtual ~B() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long B::ctor_count = 0;
+long B::dtor_count = 0;
+
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+
+// Destruction
+int
+test04()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ {/*lifetine scope*/
+ std::auto_ptr<A> A_from_A(new A);
+ std::auto_ptr<A> A_from_B(new B);
+ std::auto_ptr<B> B_from_B(new B);
+ }/*destructors called here*/
+
+ VERIFY( A::ctor_count == 3 );
+ VERIFY( A::dtor_count == 3 );
+ VERIFY( B::ctor_count == 2 );
+ VERIFY( B::dtor_count == 2 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test04();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.5 Template class auto_ptr [lib.auto.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ virtual ~A() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long A::ctor_count = 0;
+long A::dtor_count = 0;
+
+struct B : A
+{
+ B() { ++ctor_count; }
+ virtual ~B() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long B::ctor_count = 0;
+long B::dtor_count = 0;
+
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+
+// Class member construction/destruction
+template <typename T>
+class pimpl
+{
+public:
+ pimpl() : p_impl(new T) {}
+private:
+ std::auto_ptr<T> p_impl;
+};
+
+int
+test05()
+{
+ bool test __attribute__((unused)) = true;
+ reset_count_struct __attribute__((unused)) reset;
+
+ pimpl<A>();
+ pimpl<B>();
+ VERIFY( A::ctor_count == 2 );
+ VERIFY( A::dtor_count == 2 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 1 );
+ return 0;
+}
+
+int
+main()
+{
+ test05();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.5 Template class auto_ptr [lib.auto.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ virtual ~A() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long A::ctor_count = 0;
+long A::dtor_count = 0;
+
+struct B : A
+{
+ B() { ++ctor_count; }
+ virtual ~B() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long B::ctor_count = 0;
+long B::dtor_count = 0;
+
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+// 20.4.5.2 auto_ptr members [lib.auto.ptr.members]
+
+// Member access
+int
+test06()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::auto_ptr<A> A_from_A(new A);
+ std::auto_ptr<A> A_from_A_ptr(A_from_A.release());
+ VERIFY( A_from_A.get() == 0 );
+ VERIFY( A_from_A_ptr.get() != 0 );
+ VERIFY( A_from_A_ptr->ctor_count == 1 );
+ VERIFY( (*A_from_A_ptr).dtor_count == 0 );
+
+ A* A_ptr = A_from_A_ptr.get();
+
+ A_from_A_ptr.reset(A_ptr);
+ VERIFY( A_from_A_ptr.get() == A_ptr );
+ VERIFY( A_from_A_ptr->ctor_count == 1 );
+ VERIFY( (*A_from_A_ptr).dtor_count == 0 );
+
+ A_from_A_ptr.reset(new A);
+ VERIFY( A_from_A_ptr.get() != A_ptr );
+ VERIFY( A_from_A_ptr->ctor_count == 2 );
+ VERIFY( (*A_from_A_ptr).dtor_count == 1 );
+ return 0;
+}
+
+int
+main()
+{
+ test06();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.5 Template class auto_ptr [lib.auto.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ virtual ~A() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long A::ctor_count = 0;
+long A::dtor_count = 0;
+
+struct B : A
+{
+ B() { ++ctor_count; }
+ virtual ~B() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long B::ctor_count = 0;
+long B::dtor_count = 0;
+
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+// 20.4.5.3 auto_ptr conversions [lib.auto.ptr.conv]
+
+// Parameters and return values
+template <typename T>
+static std::auto_ptr<T> source()
+{
+ return std::auto_ptr<T>(new T);
+}
+
+template <typename T>
+static void drain(std::auto_ptr<T>)
+{}
+
+int
+test07()
+{
+ bool test __attribute__((unused)) = true;
+ reset_count_struct __attribute__((unused)) reset;
+
+ drain(source<A>());
+ // The resolution of core issue 84, now a DR, breaks this call.
+ // drain<A>(source<B>());
+ drain(source<B>());
+ VERIFY( A::ctor_count == 2 );
+ VERIFY( A::dtor_count == 2 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 1 );
+ return 0;
+}
+
+int
+main()
+{
+ test07();
+ return 0;
+}
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2002, 2003, 2004, 2005, 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.5 Template class auto_ptr negative tests [lib.auto.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+// via Jack Reeves <jack_reeves@hispeed.ch>
+// libstdc++/3946
+// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html
+struct Base { };
+struct Derived : public Base { };
+
+std::auto_ptr<Derived>
+foo() { return std::auto_ptr<Derived>(new Derived); }
+
+int
+test01()
+{
+ std::auto_ptr<Base> ptr2;
+ ptr2 = new Base; // { dg-error "no match" }
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+// { dg-error "candidates" "" { target *-*-* } 224 }
+// { dg-error "::auto_ptr" "" { target *-*-* } 354 }
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers.
+
+#include <memory>
+
+template class std::auto_ptr<int>;
--- /dev/null
+// Copyright (C) 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.3.6 Binders
+
+// { dg-do compile }
+
+#include <functional>
+using namespace std;
+
+struct s
+{
+ void f_void_int_const(int) const {}
+ void f_void_int(int) {}
+ int f_int_int_const(int) const { return 1; }
+ int f_int_int(int) {return 1; }
+ void f_void_void_const() const {}
+ void f_void_void() {}
+ int f_int_void_const() const { return 1; }
+ int f_int_void() { return 1; }
+};
+
+void test01(s& a)
+{
+ mem_fun_t<void, s> p1(&s::f_void_void);
+ mem_fun_t<int, s> p2(&s::f_int_void);
+ p1(&a);
+ p2(&a);
+ mem_fun1_t<void, s, int> q1(&s::f_void_int);
+ mem_fun1_t<int, s, int> q2(&s::f_int_int);
+ q1(&a,0);
+ q2(&a,0);
+
+ (mem_fun(&s::f_void_void))(&a);
+ (mem_fun(&s::f_void_int))(&a,0);
+ (mem_fun(&s::f_int_void))(&a);
+ (mem_fun(&s::f_int_int))(&a,0);
+
+ mem_fun_ref_t<void, s> ref1(&s::f_void_void);
+ mem_fun_ref_t<int, s> ref2(&s::f_int_void);
+
+ ref1(a);
+ ref2(a);
+
+ mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int);
+ mem_fun1_ref_t<int, s, int> ref4(&s::f_int_int);
+
+ ref3(a,0);
+ ref4(a,0);
+
+ (mem_fun_ref(&s::f_void_void))(a);
+ (mem_fun_ref(&s::f_void_int))(a, 0);
+ (mem_fun_ref(&s::f_int_void))(a);
+ (mem_fun_ref(&s::f_int_int))(a, 0);
+}
+
+void test02(const s& a)
+{
+ const_mem_fun_t<void, s> p1(&s::f_void_void_const);
+ const_mem_fun_t<int, s> p2(&s::f_int_void_const);
+ p1(&a);
+ p2(&a);
+ const_mem_fun1_t<void, s, int> q1(&s::f_void_int_const);
+ const_mem_fun1_t<int, s, int> q2(&s::f_int_int_const);
+ q1(&a,0);
+ q2(&a,0);
+
+ (mem_fun(&s::f_void_void_const))(&a);
+ (mem_fun(&s::f_void_int_const))(&a, 0);
+ (mem_fun(&s::f_int_void_const))(&a);
+ (mem_fun(&s::f_int_int_const))(&a, 0);
+
+ const_mem_fun_ref_t<void, s> ref1(&s::f_void_void_const);
+ const_mem_fun_ref_t<int, s> ref2(&s::f_int_void_const);
+
+ ref1(a);
+ ref2(a);
+
+ const_mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int_const);
+ const_mem_fun1_ref_t<int, s, int> ref4(&s::f_int_int_const);
+
+ ref3(a,0);
+ ref4(a,0);
+
+ (mem_fun_ref(&s::f_void_void_const))(a);
+ (mem_fun_ref(&s::f_void_int_const))(a, 0);
+ (mem_fun_ref(&s::f_int_void_const))(a);
+ (mem_fun_ref(&s::f_int_int_const))(a, 0);
+}
--- /dev/null
+// 2001-06-11 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003, 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.3.6 Binders
+
+#include <vector>
+#include <algorithm> // for_each
+#include <functional>
+
+class Elem
+{
+public:
+ void print(int) const { }
+ void modify(int) { }
+};
+
+// libstdc++/3113
+void test01()
+{
+ std::vector<Elem> coll(2);
+ // OK
+ std::for_each(coll.begin(), coll.end(),
+ std::bind2nd(std::mem_fun_ref(&Elem::print), 42));
+ // OK
+ std::for_each(coll.begin(), coll.end(),
+ std::bind2nd(std::mem_fun_ref(&Elem::modify), 42));
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.3.3 Comparisons
+
+#include <functional>
+
+class gnu_obj
+{
+ int i;
+public:
+ gnu_obj(int arg = 0): i(arg) { }
+ bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
+ bool operator!=(const gnu_obj& rhs) const { return i != rhs.i; }
+ bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
+};
+
+template<typename T>
+ struct gnu_t
+ {
+ bool b;
+ public:
+ gnu_t(bool arg = 0): b(arg) { }
+ bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
+ bool operator!=(const gnu_t& rhs) const { return b != rhs.b; }
+ bool operator<(const gnu_t& rhs) const { return b == rhs.b; }
+ };
+
+template struct std::not_equal_to<void*>;
+template struct std::not_equal_to<gnu_obj>;
+template struct std::not_equal_to<gnu_t<long> >;
+
+int main()
+{
+ return 0;
+}
+++ /dev/null
-// Copyright (C) 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.3.6 Binders
-
-// { dg-do compile }
-
-#include <functional>
-using namespace std;
-
-struct s
-{
- void f_void_int_const(int) const {}
- void f_void_int(int) {}
- int f_int_int_const(int) const { return 1; }
- int f_int_int(int) {return 1; }
- void f_void_void_const() const {}
- void f_void_void() {}
- int f_int_void_const() const { return 1; }
- int f_int_void() { return 1; }
-};
-
-void test01(s& a)
-{
- mem_fun_t<void, s> p1(&s::f_void_void);
- mem_fun_t<int, s> p2(&s::f_int_void);
- p1(&a);
- p2(&a);
- mem_fun1_t<void, s, int> q1(&s::f_void_int);
- mem_fun1_t<int, s, int> q2(&s::f_int_int);
- q1(&a,0);
- q2(&a,0);
-
- (mem_fun(&s::f_void_void))(&a);
- (mem_fun(&s::f_void_int))(&a,0);
- (mem_fun(&s::f_int_void))(&a);
- (mem_fun(&s::f_int_int))(&a,0);
-
- mem_fun_ref_t<void, s> ref1(&s::f_void_void);
- mem_fun_ref_t<int, s> ref2(&s::f_int_void);
-
- ref1(a);
- ref2(a);
-
- mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int);
- mem_fun1_ref_t<int, s, int> ref4(&s::f_int_int);
-
- ref3(a,0);
- ref4(a,0);
-
- (mem_fun_ref(&s::f_void_void))(a);
- (mem_fun_ref(&s::f_void_int))(a, 0);
- (mem_fun_ref(&s::f_int_void))(a);
- (mem_fun_ref(&s::f_int_int))(a, 0);
-}
-
-void test02(const s& a)
-{
- const_mem_fun_t<void, s> p1(&s::f_void_void_const);
- const_mem_fun_t<int, s> p2(&s::f_int_void_const);
- p1(&a);
- p2(&a);
- const_mem_fun1_t<void, s, int> q1(&s::f_void_int_const);
- const_mem_fun1_t<int, s, int> q2(&s::f_int_int_const);
- q1(&a,0);
- q2(&a,0);
-
- (mem_fun(&s::f_void_void_const))(&a);
- (mem_fun(&s::f_void_int_const))(&a, 0);
- (mem_fun(&s::f_int_void_const))(&a);
- (mem_fun(&s::f_int_int_const))(&a, 0);
-
- const_mem_fun_ref_t<void, s> ref1(&s::f_void_void_const);
- const_mem_fun_ref_t<int, s> ref2(&s::f_int_void_const);
-
- ref1(a);
- ref2(a);
-
- const_mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int_const);
- const_mem_fun1_ref_t<int, s, int> ref4(&s::f_int_int_const);
-
- ref3(a,0);
- ref4(a,0);
-
- (mem_fun_ref(&s::f_void_void_const))(a);
- (mem_fun_ref(&s::f_void_int_const))(a, 0);
- (mem_fun_ref(&s::f_int_void_const))(a);
- (mem_fun_ref(&s::f_int_int_const))(a, 0);
-}
+++ /dev/null
-// 2001-06-11 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2003, 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.3.6 Binders
-
-#include <vector>
-#include <algorithm> // for_each
-#include <functional>
-
-class Elem
-{
-public:
- void print(int) const { }
- void modify(int) { }
-};
-
-// libstdc++/3113
-void test01()
-{
- std::vector<Elem> coll(2);
- // OK
- std::for_each(coll.begin(), coll.end(),
- std::bind2nd(std::mem_fun_ref(&Elem::print), 42));
- // OK
- std::for_each(coll.begin(), coll.end(),
- std::bind2nd(std::mem_fun_ref(&Elem::modify), 42));
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.3.3 Comparisons
-
-#include <functional>
-
-class gnu_obj
-{
- int i;
-public:
- gnu_obj(int arg = 0): i(arg) { }
- bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
- bool operator!=(const gnu_obj& rhs) const { return i != rhs.i; }
- bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
-};
-
-template<typename T>
- struct gnu_t
- {
- bool b;
- public:
- gnu_t(bool arg = 0): b(arg) { }
- bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
- bool operator!=(const gnu_t& rhs) const { return b != rhs.b; }
- bool operator<(const gnu_t& rhs) const { return b == rhs.b; }
- };
-
-template struct std::not_equal_to<void*>;
-template struct std::not_equal_to<gnu_obj>;
-template struct std::not_equal_to<gnu_t<long> >;
-
-int main()
-{
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.4 specialized algorithms
-
-// { dg-do compile }
-
-#include <memory>
-
-// libstdc++/16505
-
-struct S { };
-
-template
- void
- std::uninitialized_fill_n<S*, int, S>(S*, int, const S&);
+++ /dev/null
-// 2001-06-14 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2002, 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.1.1 allocator members
-
-#include <memory>
-#include <stdexcept>
-#include <cstdlib>
-#include <testsuite_hooks.h>
-
-struct gnu { };
-
-bool check_new = false;
-bool check_delete = false;
-
-void*
-operator new(std::size_t n) throw(std::bad_alloc)
-{
- check_new = true;
- return std::malloc(n);
-}
-
-void operator delete(void *v) throw()
-{
- check_delete = true;
- return std::free(v);
-}
-
-void test01()
-{
- bool test __attribute__((unused)) = true;
- std::allocator<gnu> obj;
-
- // NB: These should work for various size allocation and
- // deallocations. Currently, they only work as expected for sizes >
- // _MAX_BYTES as defined in stl_alloc.h, which happes to be 128.
- gnu* pobj = obj.allocate(256);
- VERIFY( check_new );
-
- obj.deallocate(pobj, 256);
- VERIFY( check_delete );
-}
-
-int main()
-{
- test01();
- return 0;
-}
-
+++ /dev/null
-// Copyright (C) 2003, 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.1.5 allocator requirements / 20.4.1.1 allocator members
-
-#include <list>
-#include <cstdlib>
-#include <testsuite_hooks.h>
-
-class Bob
-{
-public:
- static void* operator new(size_t sz)
- { return std::malloc(sz); }
-};
-
-// libstdc++/10378
-void test01()
-{
- using namespace std;
- bool test __attribute__((unused)) = true;
-
- list<Bob> uniset;
- uniset.push_back(Bob());
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.1.1 allocator members
-
-#include <memory>
-#include <testsuite_hooks.h>
-
-// libstdc++/14176
-void test02()
-{
- unsigned int len = 0;
- std::allocator<int> a;
- int* p = a.allocate(len);
- a.deallocate(p, len);
-}
-
-int main()
-{
- test02();
- return 0;
-}
+++ /dev/null
-// 2001-06-14 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2002, 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.1.1 allocator members
-
-#include <memory>
-#include <stdexcept>
-#include <testsuite_hooks.h>
-
-// libstdc++/8230
-void test02()
-{
- bool test __attribute__((unused)) = true;
- try
- {
- std::allocator<int> alloc;
- const std::allocator<int>::size_type n = alloc.max_size();
- int* p = alloc.allocate(n + 1);
- p[n] = 2002;
- }
- catch(const std::bad_alloc& e)
- {
- // Allowed.
- test = true;
- }
- catch(...)
- {
- test = false;
- }
- VERIFY( test );
-}
-
-int main()
-{
- test02();
- return 0;
-}
+++ /dev/null
-// { dg-do compile }
-
-// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02110-1301, USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-// This file tests explicit instantiation of library containers.
-
-#include <memory>
-
-template class std::allocator<int>;
+++ /dev/null
-// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.5 Template class auto_ptr [lib.auto.ptr]
-
-#include <memory>
-#include <testsuite_hooks.h>
-
-struct A
-{
- A() { ++ctor_count; }
- virtual ~A() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long A::ctor_count = 0;
-long A::dtor_count = 0;
-
-struct B : A
-{
- B() { ++ctor_count; }
- virtual ~B() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long B::ctor_count = 0;
-long B::dtor_count = 0;
-
-
-struct reset_count_struct
-{
- ~reset_count_struct()
- {
- A::ctor_count = 0;
- A::dtor_count = 0;
- B::ctor_count = 0;
- B::dtor_count = 0;
- }
-};
-
-
-// 20.4.5.1 auto_ptr constructors [lib.auto.ptr.cons]
-
-// Construction from pointer
-int
-test01()
-{
- reset_count_struct __attribute__((unused)) reset;
- bool test __attribute__((unused)) = true;
-
- std::auto_ptr<A> A_default;
- VERIFY( A_default.get() == 0 );
- VERIFY( A::ctor_count == 0 );
- VERIFY( A::dtor_count == 0 );
- VERIFY( B::ctor_count == 0 );
- VERIFY( B::dtor_count == 0 );
-
- std::auto_ptr<A> A_from_A(new A);
- VERIFY( A_from_A.get() != 0 );
- VERIFY( A::ctor_count == 1 );
- VERIFY( A::dtor_count == 0 );
- VERIFY( B::ctor_count == 0 );
- VERIFY( B::dtor_count == 0 );
-
- std::auto_ptr<A> A_from_B(new B);
- VERIFY( A_from_B.get() != 0 );
- VERIFY( A::ctor_count == 2 );
- VERIFY( A::dtor_count == 0 );
- VERIFY( B::ctor_count == 1 );
- VERIFY( B::dtor_count == 0 );
-
- return 0;
-}
-
-int
-main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.5 Template class auto_ptr [lib.auto.ptr]
-
-#include <memory>
-#include <testsuite_hooks.h>
-
-struct A
-{
- A() { ++ctor_count; }
- virtual ~A() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long A::ctor_count = 0;
-long A::dtor_count = 0;
-
-struct B : A
-{
- B() { ++ctor_count; }
- virtual ~B() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long B::ctor_count = 0;
-long B::dtor_count = 0;
-
-
-struct reset_count_struct
-{
- ~reset_count_struct()
- {
- A::ctor_count = 0;
- A::dtor_count = 0;
- B::ctor_count = 0;
- B::dtor_count = 0;
- }
-};
-
-// Construction from std::auto_ptr
-int
-test02()
-{
- reset_count_struct __attribute__((unused)) reset;
- bool test __attribute__((unused)) = true;
-
- std::auto_ptr<A> A_from_A(new A);
- std::auto_ptr<B> B_from_B(new B);
-
- std::auto_ptr<A> A_from_ptr_A(A_from_A);
- std::auto_ptr<A> A_from_ptr_B(B_from_B);
- VERIFY( A_from_A.get() == 0 );
- VERIFY( B_from_B.get() == 0 );
- VERIFY( A_from_ptr_A.get() != 0 );
- VERIFY( A_from_ptr_B.get() != 0 );
- VERIFY( A::ctor_count == 2 );
- VERIFY( A::dtor_count == 0 );
- VERIFY( B::ctor_count == 1 );
- VERIFY( B::dtor_count == 0 );
-
- return 0;
-}
-
-int
-main()
-{
- test02();
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.5 Template class auto_ptr [lib.auto.ptr]
-
-#include <memory>
-#include <testsuite_hooks.h>
-
-struct A
-{
- A() { ++ctor_count; }
- virtual ~A() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long A::ctor_count = 0;
-long A::dtor_count = 0;
-
-struct B : A
-{
- B() { ++ctor_count; }
- virtual ~B() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long B::ctor_count = 0;
-long B::dtor_count = 0;
-
-
-struct reset_count_struct
-{
- ~reset_count_struct()
- {
- A::ctor_count = 0;
- A::dtor_count = 0;
- B::ctor_count = 0;
- B::dtor_count = 0;
- }
-};
-
-// Assignment from std::auto_ptr
-int
-test03()
-{
- reset_count_struct __attribute__((unused)) reset;
- bool test __attribute__((unused)) = true;
-
- std::auto_ptr<A> A_from_ptr_A;
- std::auto_ptr<A> A_from_ptr_B;
- std::auto_ptr<A> A_from_A(new A);
- std::auto_ptr<B> B_from_B(new B);
-
- A_from_ptr_A = A_from_A;
- A_from_ptr_B = B_from_B;
- VERIFY( A_from_A.get() == 0 );
- VERIFY( B_from_B.get() == 0 );
- VERIFY( A_from_ptr_A.get() != 0 );
- VERIFY( A_from_ptr_B.get() != 0 );
- VERIFY( A::ctor_count == 2 );
- VERIFY( A::dtor_count == 0 );
- VERIFY( B::ctor_count == 1 );
- VERIFY( B::dtor_count == 0 );
-
- return 0;
-}
-
-int
-main()
-{
- test03();
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.5 Template class auto_ptr [lib.auto.ptr]
-
-#include <memory>
-#include <testsuite_hooks.h>
-
-// libstdc++/3946
-// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html
-struct Base { };
-struct Derived : public Base { };
-
-std::auto_ptr<Derived>
-conversiontest08() { return std::auto_ptr<Derived>(new Derived); }
-
-void
-test08()
-{
- std::auto_ptr<Base> ptr;
- ptr = conversiontest08();
-}
-
-
-int
-main()
-{
- test08();
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.5 Template class auto_ptr [lib.auto.ptr]
-
-#include <memory>
-#include <testsuite_hooks.h>
-
-struct A
-{
- A() { ++ctor_count; }
- virtual ~A() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long A::ctor_count = 0;
-long A::dtor_count = 0;
-
-struct B : A
-{
- B() { ++ctor_count; }
- virtual ~B() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long B::ctor_count = 0;
-long B::dtor_count = 0;
-
-
-struct reset_count_struct
-{
- ~reset_count_struct()
- {
- A::ctor_count = 0;
- A::dtor_count = 0;
- B::ctor_count = 0;
- B::dtor_count = 0;
- }
-};
-
-
-// Destruction
-int
-test04()
-{
- reset_count_struct __attribute__((unused)) reset;
- bool test __attribute__((unused)) = true;
-
- {/*lifetine scope*/
- std::auto_ptr<A> A_from_A(new A);
- std::auto_ptr<A> A_from_B(new B);
- std::auto_ptr<B> B_from_B(new B);
- }/*destructors called here*/
-
- VERIFY( A::ctor_count == 3 );
- VERIFY( A::dtor_count == 3 );
- VERIFY( B::ctor_count == 2 );
- VERIFY( B::dtor_count == 2 );
-
- return 0;
-}
-
-int
-main()
-{
- test04();
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.5 Template class auto_ptr [lib.auto.ptr]
-
-#include <memory>
-#include <testsuite_hooks.h>
-
-struct A
-{
- A() { ++ctor_count; }
- virtual ~A() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long A::ctor_count = 0;
-long A::dtor_count = 0;
-
-struct B : A
-{
- B() { ++ctor_count; }
- virtual ~B() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long B::ctor_count = 0;
-long B::dtor_count = 0;
-
-
-struct reset_count_struct
-{
- ~reset_count_struct()
- {
- A::ctor_count = 0;
- A::dtor_count = 0;
- B::ctor_count = 0;
- B::dtor_count = 0;
- }
-};
-
-
-// Class member construction/destruction
-template <typename T>
-class pimpl
-{
-public:
- pimpl() : p_impl(new T) {}
-private:
- std::auto_ptr<T> p_impl;
-};
-
-int
-test05()
-{
- bool test __attribute__((unused)) = true;
- reset_count_struct __attribute__((unused)) reset;
-
- pimpl<A>();
- pimpl<B>();
- VERIFY( A::ctor_count == 2 );
- VERIFY( A::dtor_count == 2 );
- VERIFY( B::ctor_count == 1 );
- VERIFY( B::dtor_count == 1 );
- return 0;
-}
-
-int
-main()
-{
- test05();
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.5 Template class auto_ptr [lib.auto.ptr]
-
-#include <memory>
-#include <testsuite_hooks.h>
-
-struct A
-{
- A() { ++ctor_count; }
- virtual ~A() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long A::ctor_count = 0;
-long A::dtor_count = 0;
-
-struct B : A
-{
- B() { ++ctor_count; }
- virtual ~B() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long B::ctor_count = 0;
-long B::dtor_count = 0;
-
-
-struct reset_count_struct
-{
- ~reset_count_struct()
- {
- A::ctor_count = 0;
- A::dtor_count = 0;
- B::ctor_count = 0;
- B::dtor_count = 0;
- }
-};
-
-// 20.4.5.2 auto_ptr members [lib.auto.ptr.members]
-
-// Member access
-int
-test06()
-{
- reset_count_struct __attribute__((unused)) reset;
- bool test __attribute__((unused)) = true;
-
- std::auto_ptr<A> A_from_A(new A);
- std::auto_ptr<A> A_from_A_ptr(A_from_A.release());
- VERIFY( A_from_A.get() == 0 );
- VERIFY( A_from_A_ptr.get() != 0 );
- VERIFY( A_from_A_ptr->ctor_count == 1 );
- VERIFY( (*A_from_A_ptr).dtor_count == 0 );
-
- A* A_ptr = A_from_A_ptr.get();
-
- A_from_A_ptr.reset(A_ptr);
- VERIFY( A_from_A_ptr.get() == A_ptr );
- VERIFY( A_from_A_ptr->ctor_count == 1 );
- VERIFY( (*A_from_A_ptr).dtor_count == 0 );
-
- A_from_A_ptr.reset(new A);
- VERIFY( A_from_A_ptr.get() != A_ptr );
- VERIFY( A_from_A_ptr->ctor_count == 2 );
- VERIFY( (*A_from_A_ptr).dtor_count == 1 );
- return 0;
-}
-
-int
-main()
-{
- test06();
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2000, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.5 Template class auto_ptr [lib.auto.ptr]
-
-#include <memory>
-#include <testsuite_hooks.h>
-
-struct A
-{
- A() { ++ctor_count; }
- virtual ~A() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long A::ctor_count = 0;
-long A::dtor_count = 0;
-
-struct B : A
-{
- B() { ++ctor_count; }
- virtual ~B() { ++dtor_count; }
- static long ctor_count;
- static long dtor_count;
-};
-long B::ctor_count = 0;
-long B::dtor_count = 0;
-
-
-struct reset_count_struct
-{
- ~reset_count_struct()
- {
- A::ctor_count = 0;
- A::dtor_count = 0;
- B::ctor_count = 0;
- B::dtor_count = 0;
- }
-};
-
-// 20.4.5.3 auto_ptr conversions [lib.auto.ptr.conv]
-
-// Parameters and return values
-template <typename T>
-static std::auto_ptr<T> source()
-{
- return std::auto_ptr<T>(new T);
-}
-
-template <typename T>
-static void drain(std::auto_ptr<T>)
-{}
-
-int
-test07()
-{
- bool test __attribute__((unused)) = true;
- reset_count_struct __attribute__((unused)) reset;
-
- drain(source<A>());
- // The resolution of core issue 84, now a DR, breaks this call.
- // drain<A>(source<B>());
- drain(source<B>());
- VERIFY( A::ctor_count == 2 );
- VERIFY( A::dtor_count == 2 );
- VERIFY( B::ctor_count == 1 );
- VERIFY( B::dtor_count == 1 );
- return 0;
-}
-
-int
-main()
-{
- test07();
- return 0;
-}
+++ /dev/null
-// { dg-do compile }
-
-// Copyright (C) 2002, 2003, 2004, 2005, 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.5 Template class auto_ptr negative tests [lib.auto.ptr]
-
-#include <memory>
-#include <testsuite_hooks.h>
-
-// via Jack Reeves <jack_reeves@hispeed.ch>
-// libstdc++/3946
-// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html
-struct Base { };
-struct Derived : public Base { };
-
-std::auto_ptr<Derived>
-foo() { return std::auto_ptr<Derived>(new Derived); }
-
-int
-test01()
-{
- std::auto_ptr<Base> ptr2;
- ptr2 = new Base; // { dg-error "no match" }
- return 0;
-}
-
-int
-main()
-{
- test01();
- return 0;
-}
-// { dg-error "candidates" "" { target *-*-* } 224 }
-// { dg-error "::auto_ptr" "" { target *-*-* } 354 }
+++ /dev/null
-// { dg-do compile }
-
-// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02110-1301, USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-// This file tests explicit instantiation of library containers.
-
-#include <memory>
-
-template class std::auto_ptr<int>;
+++ /dev/null
-// { dg-do compile }
-
-// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2003, 2007 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.2 raw storage iterator
-
-#include <memory>
-
-void test01()
-{
- using namespace std;
-
- // Check for required base class.
- long l;
- typedef raw_storage_iterator<long*, long> test_iterator;
- typedef iterator<output_iterator_tag, void, void, void, void> base_iterator;
- test_iterator rs_it(&l);
- base_iterator* base __attribute__((unused)) = &rs_it;
-}
+++ /dev/null
-// { dg-do compile }
-
-// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02110-1301, USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-// This file tests explicit instantiation of library containers.
-
-#include <memory>
-
-template class std::raw_storage_iterator<int*, int>;
+++ /dev/null
-// { dg-do compile }
-// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2003, 2007 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.2 raw storage iterator
-
-#include <memory>
-
-void test01()
-{
- using namespace std;
-
- // Check for required typedefs
- long l;
- typedef raw_storage_iterator<long*, long> test_iterator;
- typedef test_iterator::value_type value_type;
- typedef test_iterator::difference_type difference_type;
- typedef test_iterator::pointer pointer;
- typedef test_iterator::reference reference;
- typedef test_iterator::iterator_category iteratory_category;
-}
+++ /dev/null
-// 2002-01-24 Phil Edwards <pme@gcc.gnu.org>
-
-// Copyright (C) 2002 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.4.3 temporary buffers
-
-#include <memory>
-#include <testsuite_hooks.h>
-
-struct junk { char j[12]; };
-
-int main(void)
-{
- bool test __attribute__((unused)) = true;
-
- std::pair<junk*,ptrdiff_t> results = std::get_temporary_buffer<junk>(5);
-
- if (results.second != 0)
- {
- // make sure it works: test the returned capacity, and then construct
- // some junk in the buffer.
- // XXX
- VERIFY( results.first != 0 );
- }
- else
- {
- // if it says it didn't work, make sure it didn't work
- VERIFY( results.first == 0 );
- }
-
- std::return_temporary_buffer(results.first);
-
- return 0;
-}
--- /dev/null
+// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.2.2 Pairs
+
+#include <utility>
+#include <testsuite_hooks.h>
+
+class gnu_obj
+{
+ int i;
+public:
+ gnu_obj(int arg = 0): i(arg) { }
+ bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
+ bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
+};
+
+template<typename T>
+ struct gnu_t
+ {
+ bool b;
+ public:
+ gnu_t(bool arg = 0): b(arg) { }
+ bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
+ bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
+ };
+
+
+// heterogeneous
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::pair<bool, long> p_bl_1(true, 433);
+ std::pair<bool, long> p_bl_2 = std::make_pair(true, 433);
+ VERIFY( p_bl_1 == p_bl_2 );
+ VERIFY( !(p_bl_1 < p_bl_2) );
+
+ std::pair<const char*, float> p_sf_1("total enlightenment", 433.00);
+ std::pair<const char*, float> p_sf_2 = std::make_pair("total enlightenment",
+ 433.00);
+ VERIFY( p_sf_1 == p_sf_2 );
+ VERIFY( !(p_sf_1 < p_sf_2) );
+
+ std::pair<const char*, gnu_obj> p_sg_1("enlightenment", gnu_obj(5));
+ std::pair<const char*, gnu_obj> p_sg_2 = std::make_pair("enlightenment",
+ gnu_obj(5));
+ VERIFY( p_sg_1 == p_sg_2 );
+ VERIFY( !(p_sg_1 < p_sg_2) );
+
+ std::pair<gnu_t<long>, gnu_obj> p_st_1(gnu_t<long>(false), gnu_obj(5));
+ std::pair<gnu_t<long>, gnu_obj> p_st_2 = std::make_pair(gnu_t<long>(false),
+ gnu_obj(5));
+ VERIFY( p_st_1 == p_st_2 );
+ VERIFY( !(p_st_1 < p_st_2) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.2.2 Pairs
+
+#include <utility>
+#include <testsuite_hooks.h>
+
+class gnu_obj
+{
+ int i;
+public:
+ gnu_obj(int arg = 0): i(arg) { }
+ bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
+ bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
+};
+
+template<typename T>
+ struct gnu_t
+ {
+ bool b;
+ public:
+ gnu_t(bool arg = 0): b(arg) { }
+ bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
+ bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
+ };
+
+// homogeneous
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::pair<bool, bool> p_bb_1(true, false);
+ std::pair<bool, bool> p_bb_2 = std::make_pair(true, false);
+ VERIFY( p_bb_1 == p_bb_2 );
+ VERIFY( !(p_bb_1 < p_bb_2) );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.2.2 Pairs
+
+#include <utility>
+#include <testsuite_hooks.h>
+
+class gnu_obj
+{
+ int i;
+public:
+ gnu_obj(int arg = 0): i(arg) { }
+ bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
+ bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
+};
+
+template<typename T>
+ struct gnu_t
+ {
+ bool b;
+ public:
+ gnu_t(bool arg = 0): b(arg) { }
+ bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
+ bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
+ };
+
+
+// const
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::pair<bool, long> p_bl_1(true, 433);
+ const std::pair<bool, long> p_bl_2 = std::make_pair(true, 433);
+ VERIFY( p_bl_1 == p_bl_2 );
+ VERIFY( !(p_bl_1 < p_bl_2) );
+
+ const std::pair<const char*, float> p_sf_1("total enlightenment", 433.00);
+ const std::pair<const char*, float> p_sf_2 =
+ std::make_pair("total enlightenment", 433.00);
+ VERIFY( p_sf_1 == p_sf_2 );
+ VERIFY( !(p_sf_1 < p_sf_2) );
+
+ const std::pair<const char*, gnu_obj> p_sg_1("enlightenment", gnu_obj(5));
+ const std::pair<const char*, gnu_obj> p_sg_2 =
+ std::make_pair("enlightenment", gnu_obj(5));
+ VERIFY( p_sg_1 == p_sg_2 );
+ VERIFY( !(p_sg_1 < p_sg_2) );
+
+ const std::pair<gnu_t<long>, gnu_obj> p_st_1(gnu_t<long>(false), gnu_obj(5));
+ const std::pair<gnu_t<long>, gnu_obj> p_st_2 =
+ std::make_pair(gnu_t<long>(false), gnu_obj(5));
+ VERIFY( p_st_1 == p_st_2 );
+ VERIFY( !(p_st_1 < p_st_2) );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.2.2 Pairs
+
+#include <utility>
+#include <testsuite_hooks.h>
+
+class gnu_obj
+{
+ int i;
+public:
+ gnu_obj(int arg = 0): i(arg) { }
+ bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
+ bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
+};
+
+template<typename T>
+ struct gnu_t
+ {
+ bool b;
+ public:
+ gnu_t(bool arg = 0): b(arg) { }
+ bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
+ bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
+ };
+
+// const&
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+ const gnu_obj& obj1 = gnu_obj(5);
+ const std::pair<const char*, gnu_obj> p_sg_1("enlightenment", obj1);
+ const std::pair<const char*, gnu_obj> p_sg_2 =
+ std::make_pair("enlightenment", obj1);
+ VERIFY( p_sg_1 == p_sg_2 );
+ VERIFY( !(p_sg_1 < p_sg_2) );
+
+ const gnu_t<long>& tmpl1 = gnu_t<long>(false);
+ const std::pair<gnu_t<long>, gnu_obj> p_st_1(tmpl1, obj1);
+ const std::pair<gnu_t<long>, gnu_obj> p_st_2 = std::make_pair(tmpl1, obj1);
+ VERIFY( p_st_1 == p_st_2 );
+ VERIFY( !(p_st_1 < p_st_2) );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers.
+
+#include <utility>
+
+template class std::pair<int, long>;
--- /dev/null
+// { dg-do compile }
+
+// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003, 2007 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.2 raw storage iterator
+
+#include <memory>
+
+void test01()
+{
+ using namespace std;
+
+ // Check for required base class.
+ long l;
+ typedef raw_storage_iterator<long*, long> test_iterator;
+ typedef iterator<output_iterator_tag, void, void, void, void> base_iterator;
+ test_iterator rs_it(&l);
+ base_iterator* base __attribute__((unused)) = &rs_it;
+}
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers.
+
+#include <memory>
+
+template class std::raw_storage_iterator<int*, int>;
--- /dev/null
+// { dg-do compile }
+// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003, 2007 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.2 raw storage iterator
+
+#include <memory>
+
+void test01()
+{
+ using namespace std;
+
+ // Check for required typedefs
+ long l;
+ typedef raw_storage_iterator<long*, long> test_iterator;
+ typedef test_iterator::value_type value_type;
+ typedef test_iterator::difference_type difference_type;
+ typedef test_iterator::pointer pointer;
+ typedef test_iterator::reference reference;
+ typedef test_iterator::iterator_category iteratory_category;
+}
--- /dev/null
+// 2002-04-13 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2002, 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.2.1 Operators
+
+#include <utility>
+#include <vector>
+
+using namespace std::rel_ops;
+
+// libstdc++/3628
+void test01()
+{
+ std::vector<int> v;
+ std::vector<int>::iterator vi;
+ v.push_back(1);
+ vi = v.end();
+ vi != v.begin();
+ vi > v.begin();
+ vi <= v.begin();
+ vi >= v.begin();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
--- /dev/null
+// Copyright (C) 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.4 specialized algorithms
+
+// { dg-do compile }
+
+#include <memory>
+
+// libstdc++/16505
+
+struct S { };
+
+template
+ void
+ std::uninitialized_fill_n<S*, int, S>(S*, int, const S&);
--- /dev/null
+// 2002-01-24 Phil Edwards <pme@gcc.gnu.org>
+
+// Copyright (C) 2002 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 20.4.3 temporary buffers
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct junk { char j[12]; };
+
+int main(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ std::pair<junk*,ptrdiff_t> results = std::get_temporary_buffer<junk>(5);
+
+ if (results.second != 0)
+ {
+ // make sure it works: test the returned capacity, and then construct
+ // some junk in the buffer.
+ // XXX
+ VERIFY( results.first != 0 );
+ }
+ else
+ {
+ // if it says it didn't work, make sure it didn't work
+ VERIFY( results.first == 0 );
+ }
+
+ std::return_temporary_buffer(results.first);
+
+ return 0;
+}
+++ /dev/null
-// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.2.2 Pairs
-
-#include <utility>
-#include <testsuite_hooks.h>
-
-class gnu_obj
-{
- int i;
-public:
- gnu_obj(int arg = 0): i(arg) { }
- bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
- bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
-};
-
-template<typename T>
- struct gnu_t
- {
- bool b;
- public:
- gnu_t(bool arg = 0): b(arg) { }
- bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
- bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
- };
-
-
-// heterogeneous
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- std::pair<bool, long> p_bl_1(true, 433);
- std::pair<bool, long> p_bl_2 = std::make_pair(true, 433);
- VERIFY( p_bl_1 == p_bl_2 );
- VERIFY( !(p_bl_1 < p_bl_2) );
-
- std::pair<const char*, float> p_sf_1("total enlightenment", 433.00);
- std::pair<const char*, float> p_sf_2 = std::make_pair("total enlightenment",
- 433.00);
- VERIFY( p_sf_1 == p_sf_2 );
- VERIFY( !(p_sf_1 < p_sf_2) );
-
- std::pair<const char*, gnu_obj> p_sg_1("enlightenment", gnu_obj(5));
- std::pair<const char*, gnu_obj> p_sg_2 = std::make_pair("enlightenment",
- gnu_obj(5));
- VERIFY( p_sg_1 == p_sg_2 );
- VERIFY( !(p_sg_1 < p_sg_2) );
-
- std::pair<gnu_t<long>, gnu_obj> p_st_1(gnu_t<long>(false), gnu_obj(5));
- std::pair<gnu_t<long>, gnu_obj> p_st_2 = std::make_pair(gnu_t<long>(false),
- gnu_obj(5));
- VERIFY( p_st_1 == p_st_2 );
- VERIFY( !(p_st_1 < p_st_2) );
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.2.2 Pairs
-
-#include <utility>
-#include <testsuite_hooks.h>
-
-class gnu_obj
-{
- int i;
-public:
- gnu_obj(int arg = 0): i(arg) { }
- bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
- bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
-};
-
-template<typename T>
- struct gnu_t
- {
- bool b;
- public:
- gnu_t(bool arg = 0): b(arg) { }
- bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
- bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
- };
-
-// homogeneous
-void test02()
-{
- bool test __attribute__((unused)) = true;
-
- std::pair<bool, bool> p_bb_1(true, false);
- std::pair<bool, bool> p_bb_2 = std::make_pair(true, false);
- VERIFY( p_bb_1 == p_bb_2 );
- VERIFY( !(p_bb_1 < p_bb_2) );
-}
-
-int main()
-{
- test02();
- return 0;
-}
+++ /dev/null
-// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.2.2 Pairs
-
-#include <utility>
-#include <testsuite_hooks.h>
-
-class gnu_obj
-{
- int i;
-public:
- gnu_obj(int arg = 0): i(arg) { }
- bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
- bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
-};
-
-template<typename T>
- struct gnu_t
- {
- bool b;
- public:
- gnu_t(bool arg = 0): b(arg) { }
- bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
- bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
- };
-
-
-// const
-void test03()
-{
- bool test __attribute__((unused)) = true;
-
- const std::pair<bool, long> p_bl_1(true, 433);
- const std::pair<bool, long> p_bl_2 = std::make_pair(true, 433);
- VERIFY( p_bl_1 == p_bl_2 );
- VERIFY( !(p_bl_1 < p_bl_2) );
-
- const std::pair<const char*, float> p_sf_1("total enlightenment", 433.00);
- const std::pair<const char*, float> p_sf_2 =
- std::make_pair("total enlightenment", 433.00);
- VERIFY( p_sf_1 == p_sf_2 );
- VERIFY( !(p_sf_1 < p_sf_2) );
-
- const std::pair<const char*, gnu_obj> p_sg_1("enlightenment", gnu_obj(5));
- const std::pair<const char*, gnu_obj> p_sg_2 =
- std::make_pair("enlightenment", gnu_obj(5));
- VERIFY( p_sg_1 == p_sg_2 );
- VERIFY( !(p_sg_1 < p_sg_2) );
-
- const std::pair<gnu_t<long>, gnu_obj> p_st_1(gnu_t<long>(false), gnu_obj(5));
- const std::pair<gnu_t<long>, gnu_obj> p_st_2 =
- std::make_pair(gnu_t<long>(false), gnu_obj(5));
- VERIFY( p_st_1 == p_st_2 );
- VERIFY( !(p_st_1 < p_st_2) );
-}
-
-int main()
-{
- test03();
- return 0;
-}
+++ /dev/null
-// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.2.2 Pairs
-
-#include <utility>
-#include <testsuite_hooks.h>
-
-class gnu_obj
-{
- int i;
-public:
- gnu_obj(int arg = 0): i(arg) { }
- bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
- bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
-};
-
-template<typename T>
- struct gnu_t
- {
- bool b;
- public:
- gnu_t(bool arg = 0): b(arg) { }
- bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
- bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
- };
-
-// const&
-void test04()
-{
- bool test __attribute__((unused)) = true;
- const gnu_obj& obj1 = gnu_obj(5);
- const std::pair<const char*, gnu_obj> p_sg_1("enlightenment", obj1);
- const std::pair<const char*, gnu_obj> p_sg_2 =
- std::make_pair("enlightenment", obj1);
- VERIFY( p_sg_1 == p_sg_2 );
- VERIFY( !(p_sg_1 < p_sg_2) );
-
- const gnu_t<long>& tmpl1 = gnu_t<long>(false);
- const std::pair<gnu_t<long>, gnu_obj> p_st_1(tmpl1, obj1);
- const std::pair<gnu_t<long>, gnu_obj> p_st_2 = std::make_pair(tmpl1, obj1);
- VERIFY( p_st_1 == p_st_2 );
- VERIFY( !(p_st_1 < p_st_2) );
-}
-
-int main()
-{
- test04();
- return 0;
-}
+++ /dev/null
-// { dg-do compile }
-
-// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02110-1301, USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-// This file tests explicit instantiation of library containers.
-
-#include <utility>
-
-template class std::pair<int, long>;
+++ /dev/null
-// 2002-04-13 Paolo Carlini <pcarlini@unitus.it>
-
-// Copyright (C) 2002, 2004, 2005 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 20.2.1 Operators
-
-#include <utility>
-#include <vector>
-
-using namespace std::rel_ops;
-
-// libstdc++/3628
-void test01()
-{
- std::vector<int> v;
- std::vector<int>::iterator vi;
- v.push_back(1);
- vi = v.end();
- vi != v.begin();
- vi > v.begin();
- vi <= v.begin();
- vi >= v.begin();
-}
-
-int main()
-{
- test01();
- return 0;
-}
-
+++ /dev/null
-// Copyright (C) 2006 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-#include <valarray>
-#include <testsuite_hooks.h>
-
-// libstdc++/27867
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- std::valarray<int> v1(100, 1);
- std::valarray<int> v2(100, 1);
- std::valarray<bool> v3(true, 1);
-
- std::valarray<bool> resl(1);
- resl = ((v1 == v2) == v3);
- VERIFY( resl[0] == true );
-
- std::valarray<bool> resr(1);
- resr = (v3 == (v1 == v2));
- VERIFY( resr[0] == true );
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 2006-07-15 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-#include <valarray>
-#include <testsuite_hooks.h>
-
-// libstdc++/28277
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- const std::valarray<int> v1(1, 5000000);
-
- const std::valarray<int> v2 = v1.shift(1);
- VERIFY( v2.size() == v1.size() );
- VERIFY( v2[v1.size() - 1] == 0 );
-
- const std::valarray<int> v3 = v2.cshift(-1);
- VERIFY( v3.size() == v2.size() );
- VERIFY( v3[0] == 0 );
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 2007-01-11 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-#include <valarray>
-#include <testsuite_hooks.h>
-
-bool
-comp_vala(const std::valarray<int>& v1, const std::valarray<int>& v2)
-{
- if (v1.size() == v2.size())
- {
- for (size_t i = 0; i < v1.size(); ++i)
- if (v1[i] != v2[i])
- return false;
- return true;
- }
- return false;
-}
-
-void
-init_vala(std::valarray<int>& v, size_t first, size_t last, int val)
-{
- for (size_t i = first; i <= last; ++i)
- v[i] = val++;
-}
-
-// libstdc++/30416
-void test01()
-{
- bool test __attribute__((unused)) = true;
- using namespace std;
-
- // shift
- valarray<int> v1;
- valarray<int> v1_ris(v1.shift(0));
- VERIFY( comp_vala(v1, v1_ris) );
-
- valarray<int> v2;
- valarray<int> v2_ris(v2.shift(10));
- VERIFY( comp_vala(v2, v2_ris) );
-
- valarray<int> v3;
- valarray<int> v3_ris(v3.shift(-10));
- VERIFY( comp_vala(v3, v3_ris) );
-
- valarray<int> v4(10);
- valarray<int> v4_ris(v4.shift(0));
- VERIFY( comp_vala(v4, v4_ris) );
-
- valarray<int> v5(10);
- init_vala(v5, 0, 9, 1);
- valarray<int> v5_ref(10);
-
- valarray<int> v5_ris(v5.shift(16));
- VERIFY( comp_vala(v5_ris, v5_ref) );
-
- valarray<int> v6(10);
- init_vala(v6, 0, 9, 1);
- valarray<int> v6_ref(10);
-
- valarray<int> v6_ris(v6.shift(-16));
- VERIFY( comp_vala(v6_ris, v6_ref) );
-
- valarray<int> v7(10);
- init_vala(v7, 0, 9, 1);
- valarray<int> v7_ref(10);
-
- valarray<int> v7_ris(v7.shift(10));
- VERIFY( comp_vala(v7_ris, v7_ref) );
-
- valarray<int> v8(10);
- init_vala(v8, 0, 9, 1);
- valarray<int> v8_ref(10);
-
- valarray<int> v8_ris(v8.shift(-10));
- VERIFY( comp_vala(v8_ris, v8_ref) );
-
- valarray<int> v9(10);
- init_vala(v9, 0, 9, 1);
- valarray<int> v9_ref(10);
- init_vala(v9_ref, 0, 3, 7);
-
- valarray<int> v9_ris(v9.shift(6));
- VERIFY( comp_vala(v9_ris, v9_ref) );
-
- valarray<int> v10(10);
- init_vala(v10, 0, 9, 1);
- valarray<int> v10_ref(10);
- init_vala(v10_ref, 6, 9, 1);
-
- valarray<int> v10_ris(v10.shift(-6));
- VERIFY( comp_vala(v10_ris, v10_ref) );
-
- // cshift
- valarray<int> v11;
- valarray<int> v11_ris(v11.cshift(0));
- VERIFY( comp_vala(v11, v11_ris) );
-
- valarray<int> v12;
- valarray<int> v12_ris(v12.cshift(10));
- VERIFY( comp_vala(v12, v12_ris) );
-
- valarray<int> v13;
- valarray<int> v13_ris(v13.cshift(-10));
- VERIFY( comp_vala(v13, v13_ris) );
-
- valarray<int> v14(10);
- valarray<int> v14_ris(v14.cshift(0));
- VERIFY( comp_vala(v14, v14_ris) );
-
- valarray<int> v15(10);
- init_vala(v15, 0, 9, 1);
- valarray<int> v15_ref(10);
- init_vala(v15_ref, 0, 3, 7);
- init_vala(v15_ref, 4, 9, 1);
-
- valarray<int> v15_ris(v15.cshift(16));
- VERIFY( comp_vala(v15_ris, v15_ref) );
-
- valarray<int> v16(10);
- init_vala(v16, 0, 9, 1);
- valarray<int> v16_ref(10);
- init_vala(v16_ref, 0, 5, 5);
- init_vala(v16_ref, 6, 9, 1);
-
- valarray<int> v16_ris(v16.cshift(-16));
- VERIFY( comp_vala(v16_ris, v16_ref) );
-
- valarray<int> v17(10);
- init_vala(v17, 0, 9, 1);
-
- valarray<int> v17_ris(v15.cshift(10));
- VERIFY( comp_vala(v17, v17_ris) );
-
- valarray<int> v18(10);
- init_vala(v18, 0, 9, 1);
-
- valarray<int> v18_ris(v18.cshift(-10));
- VERIFY( comp_vala(v18, v18_ris) );
-
- valarray<int> v19(10);
- init_vala(v19, 0, 9, 1);
- valarray<int> v19_ref(10);
- init_vala(v19_ref, 0, 3, 7);
- init_vala(v19_ref, 4, 9, 1);
-
- valarray<int> v19_ris(v15.cshift(6));
- VERIFY( comp_vala(v19_ris, v19_ref) );
-
- valarray<int> v20(10);
- init_vala(v20, 0, 9, 1);
- valarray<int> v20_ref(10);
- init_vala(v20_ref, 0, 5, 5);
- init_vala(v20_ref, 6, 9, 1);
-
- valarray<int> v20_ris(v20.cshift(-6));
- VERIFY( comp_vala(v20_ris, v20_ref) );
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 19990805 gdr
-//
-// XXX: to impove later.
-// Origin: Andreas Amann <amann@physik.tu-berlin.de>
-// CXXFLAGS: -g
-
-#include <iostream>
-#include <valarray>
-
-
-int main()
-{
- std::valarray<double> a(10), b(10), c(10), d(10);
-
- a = 1.2;
- b = 3.1;
-
- c = 4.0;
-
- d = ( 2.0 * b + a ); // works
- std::cout << "d[4] = " << d[4] << std::endl;
-
- d = (a * 2.0 + b ); // works
- std::cout << "d[4] = " << d[4] << std::endl;
-
- d = (a + b * 2.0 ); // segfaults!
- std::cout << "d[4] = " << d[4] << std::endl;
- d = (a + 2.0* b );
-
- std::cout << "d[4] = " << d[4] << std::endl;
- d = (a + 2.0* b );
- std::cout << "d[4] = " << d[4] << std::endl;
- d = (a + 2.0* b );
-
- std::cout << "d[4] = " << d[4] << std::endl;
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-#include <valarray>
-#include <testsuite_hooks.h>
-
-// DR 543. valarray slice default constructor
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- std::valarray<int> v1(10);
- std::valarray<int> v2 = v1[std::slice()];
- VERIFY( v2.size() == 0 );
-
- std::valarray<int> v3(10);
- std::valarray<int> v4 = v3[std::gslice()];
- VERIFY( v4.size() == 0 );
-}
-
-int main()
-{
- test01();
- return 0;
-}
--- /dev/null
+// 20010613 gdr
+
+// Copyright (C) 2001, 2002, 2003 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+
+// This is DR-253. Test for accessible assignment-operators.
+#include <valarray>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ bool test __attribute__((unused)) = true;
+ using std::valarray;
+ using std::slice;
+ valarray<int> v(1, 10), w(2, 10);
+
+ w[slice(0, 3, 3)] = v[slice(2, 3, 3)];
+
+ VERIFY(v[0] == 1 && w[0] == 1);
+ VERIFY(v[3] == 1 && w[3] == 1);
+ VERIFY(v[6] == 1 && w[6] == 1);
+
+ std::slice_array<int> t = v[slice(0, 10, 1)];
+
+ return 0;
+}
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers.
+
+#include <valarray>
+
+template class std::slice_array<short>;
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// 6.2.2 Class template array
+
+#include <valarray>
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::slice_array<int> test_type;
+ typedef test_type::value_type value_type;
+}
+++ /dev/null
-// 20010613 gdr
-
-// Copyright (C) 2001, 2002, 2003 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-
-// This is DR-253. Test for accessible assignment-operators.
-#include <valarray>
-#include <testsuite_hooks.h>
-
-int main()
-{
- bool test __attribute__((unused)) = true;
- using std::valarray;
- using std::slice;
- valarray<int> v(1, 10), w(2, 10);
-
- w[slice(0, 3, 3)] = v[slice(2, 3, 3)];
-
- VERIFY(v[0] == 1 && w[0] == 1);
- VERIFY(v[3] == 1 && w[3] == 1);
- VERIFY(v[6] == 1 && w[6] == 1);
-
- std::slice_array<int> t = v[slice(0, 10, 1)];
-
- return 0;
-}
+++ /dev/null
-// 19990404 gdr
-
-// Copyright (C) 1999, 2000 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-#include <valarray>
-
-int main()
-{
- // 01: instantiation
- std::valarray<double> a(20);
-
- // 02: algo
- using std::valarray;
- valarray<double> b, c;
- double m __attribute__((unused)) = std::abs(b - c).max();
-
- return 0;
-}
--- /dev/null
+// Copyright (C) 2006 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <valarray>
+#include <testsuite_hooks.h>
+
+// libstdc++/27867
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::valarray<int> v1(100, 1);
+ std::valarray<int> v2(100, 1);
+ std::valarray<bool> v3(true, 1);
+
+ std::valarray<bool> resl(1);
+ resl = ((v1 == v2) == v3);
+ VERIFY( resl[0] == true );
+
+ std::valarray<bool> resr(1);
+ resr = (v3 == (v1 == v2));
+ VERIFY( resr[0] == true );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2006-07-15 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <valarray>
+#include <testsuite_hooks.h>
+
+// libstdc++/28277
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::valarray<int> v1(1, 5000000);
+
+ const std::valarray<int> v2 = v1.shift(1);
+ VERIFY( v2.size() == v1.size() );
+ VERIFY( v2[v1.size() - 1] == 0 );
+
+ const std::valarray<int> v3 = v2.cshift(-1);
+ VERIFY( v3.size() == v2.size() );
+ VERIFY( v3[0] == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2007-01-11 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <valarray>
+#include <testsuite_hooks.h>
+
+bool
+comp_vala(const std::valarray<int>& v1, const std::valarray<int>& v2)
+{
+ if (v1.size() == v2.size())
+ {
+ for (size_t i = 0; i < v1.size(); ++i)
+ if (v1[i] != v2[i])
+ return false;
+ return true;
+ }
+ return false;
+}
+
+void
+init_vala(std::valarray<int>& v, size_t first, size_t last, int val)
+{
+ for (size_t i = first; i <= last; ++i)
+ v[i] = val++;
+}
+
+// libstdc++/30416
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ // shift
+ valarray<int> v1;
+ valarray<int> v1_ris(v1.shift(0));
+ VERIFY( comp_vala(v1, v1_ris) );
+
+ valarray<int> v2;
+ valarray<int> v2_ris(v2.shift(10));
+ VERIFY( comp_vala(v2, v2_ris) );
+
+ valarray<int> v3;
+ valarray<int> v3_ris(v3.shift(-10));
+ VERIFY( comp_vala(v3, v3_ris) );
+
+ valarray<int> v4(10);
+ valarray<int> v4_ris(v4.shift(0));
+ VERIFY( comp_vala(v4, v4_ris) );
+
+ valarray<int> v5(10);
+ init_vala(v5, 0, 9, 1);
+ valarray<int> v5_ref(10);
+
+ valarray<int> v5_ris(v5.shift(16));
+ VERIFY( comp_vala(v5_ris, v5_ref) );
+
+ valarray<int> v6(10);
+ init_vala(v6, 0, 9, 1);
+ valarray<int> v6_ref(10);
+
+ valarray<int> v6_ris(v6.shift(-16));
+ VERIFY( comp_vala(v6_ris, v6_ref) );
+
+ valarray<int> v7(10);
+ init_vala(v7, 0, 9, 1);
+ valarray<int> v7_ref(10);
+
+ valarray<int> v7_ris(v7.shift(10));
+ VERIFY( comp_vala(v7_ris, v7_ref) );
+
+ valarray<int> v8(10);
+ init_vala(v8, 0, 9, 1);
+ valarray<int> v8_ref(10);
+
+ valarray<int> v8_ris(v8.shift(-10));
+ VERIFY( comp_vala(v8_ris, v8_ref) );
+
+ valarray<int> v9(10);
+ init_vala(v9, 0, 9, 1);
+ valarray<int> v9_ref(10);
+ init_vala(v9_ref, 0, 3, 7);
+
+ valarray<int> v9_ris(v9.shift(6));
+ VERIFY( comp_vala(v9_ris, v9_ref) );
+
+ valarray<int> v10(10);
+ init_vala(v10, 0, 9, 1);
+ valarray<int> v10_ref(10);
+ init_vala(v10_ref, 6, 9, 1);
+
+ valarray<int> v10_ris(v10.shift(-6));
+ VERIFY( comp_vala(v10_ris, v10_ref) );
+
+ // cshift
+ valarray<int> v11;
+ valarray<int> v11_ris(v11.cshift(0));
+ VERIFY( comp_vala(v11, v11_ris) );
+
+ valarray<int> v12;
+ valarray<int> v12_ris(v12.cshift(10));
+ VERIFY( comp_vala(v12, v12_ris) );
+
+ valarray<int> v13;
+ valarray<int> v13_ris(v13.cshift(-10));
+ VERIFY( comp_vala(v13, v13_ris) );
+
+ valarray<int> v14(10);
+ valarray<int> v14_ris(v14.cshift(0));
+ VERIFY( comp_vala(v14, v14_ris) );
+
+ valarray<int> v15(10);
+ init_vala(v15, 0, 9, 1);
+ valarray<int> v15_ref(10);
+ init_vala(v15_ref, 0, 3, 7);
+ init_vala(v15_ref, 4, 9, 1);
+
+ valarray<int> v15_ris(v15.cshift(16));
+ VERIFY( comp_vala(v15_ris, v15_ref) );
+
+ valarray<int> v16(10);
+ init_vala(v16, 0, 9, 1);
+ valarray<int> v16_ref(10);
+ init_vala(v16_ref, 0, 5, 5);
+ init_vala(v16_ref, 6, 9, 1);
+
+ valarray<int> v16_ris(v16.cshift(-16));
+ VERIFY( comp_vala(v16_ris, v16_ref) );
+
+ valarray<int> v17(10);
+ init_vala(v17, 0, 9, 1);
+
+ valarray<int> v17_ris(v15.cshift(10));
+ VERIFY( comp_vala(v17, v17_ris) );
+
+ valarray<int> v18(10);
+ init_vala(v18, 0, 9, 1);
+
+ valarray<int> v18_ris(v18.cshift(-10));
+ VERIFY( comp_vala(v18, v18_ris) );
+
+ valarray<int> v19(10);
+ init_vala(v19, 0, 9, 1);
+ valarray<int> v19_ref(10);
+ init_vala(v19_ref, 0, 3, 7);
+ init_vala(v19_ref, 4, 9, 1);
+
+ valarray<int> v19_ris(v15.cshift(6));
+ VERIFY( comp_vala(v19_ris, v19_ref) );
+
+ valarray<int> v20(10);
+ init_vala(v20, 0, 9, 1);
+ valarray<int> v20_ref(10);
+ init_vala(v20_ref, 0, 5, 5);
+ init_vala(v20_ref, 6, 9, 1);
+
+ valarray<int> v20_ris(v20.cshift(-6));
+ VERIFY( comp_vala(v20_ris, v20_ref) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 19990404 gdr
+
+// Copyright (C) 1999, 2000 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <valarray>
+
+int main()
+{
+ // 02: algo
+ using std::valarray;
+ valarray<double> b, c;
+ double m __attribute__((unused)) = std::abs(b - c).max();
+
+ return 0;
+}
--- /dev/null
+// 19990805 gdr
+//
+// XXX: to impove later.
+// Origin: Andreas Amann <amann@physik.tu-berlin.de>
+// CXXFLAGS: -g
+
+#include <iostream>
+#include <valarray>
+
+
+int main()
+{
+ std::valarray<double> a(10), b(10), c(10), d(10);
+
+ a = 1.2;
+ b = 3.1;
+
+ c = 4.0;
+
+ d = ( 2.0 * b + a ); // works
+ std::cout << "d[4] = " << d[4] << std::endl;
+
+ d = (a * 2.0 + b ); // works
+ std::cout << "d[4] = " << d[4] << std::endl;
+
+ d = (a + b * 2.0 ); // segfaults!
+ std::cout << "d[4] = " << d[4] << std::endl;
+ d = (a + 2.0* b );
+
+ std::cout << "d[4] = " << d[4] << std::endl;
+ d = (a + 2.0* b );
+ std::cout << "d[4] = " << d[4] << std::endl;
+ d = (a + 2.0* b );
+
+ std::cout << "d[4] = " << d[4] << std::endl;
+ return 0;
+}
--- /dev/null
+// 20010518 gdr
+
+// Copyright (C) 2001 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <valarray>
+
+// dg-do compile
+
+template<typename P>
+ void copy(P, std::size_t) { }
+
+template<typename T>
+ void test(const std::valarray<T>& v)
+ {
+ copy(&v[0], v.size());
+ }
+
+int main()
+{
+ std::valarray<double> v(190);
+ test(v);
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <valarray>
+#include <testsuite_hooks.h>
+
+// DR 543. valarray slice default constructor
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::valarray<int> v1(10);
+ std::valarray<int> v2 = v1[std::slice()];
+ VERIFY( v2.size() == 0 );
+
+ std::valarray<int> v3(10);
+ std::valarray<int> v4 = v3[std::gslice()];
+ VERIFY( v4.size() == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2002-08-02 gdr
+
+// Copyright (C) 2002, 2003 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// Test name lookup resolutions for standard functions applied to an
+// array expression.
+// { dg-do compile }
+
+#include <valarray>
+
+namespace My
+{
+ struct Number
+ {
+ operator bool() const;
+ };
+
+ Number operator+(Number);
+ Number operator-(Number);
+ Number operator~(Number);
+
+ bool operator!(Number);
+
+ Number operator+(Number, Number);
+ Number operator-(Number, Number);
+ Number operator*(Number, Number);
+ Number operator/(Number, Number);
+ Number operator%(Number, Number);
+
+ Number operator^(Number, Number);
+ Number operator&(Number, Number);
+ Number operator|(Number, Number);
+
+ Number operator<<(Number, Number);
+ Number operator>>(Number, Number);
+
+ bool operator==(Number, Number);
+ bool operator!=(Number, Number);
+ bool operator<(Number, Number);
+ bool operator<=(Number, Number);
+ bool operator>(Number, Number);
+ bool operator>=(Number, Number);
+
+ Number abs(Number);
+
+ Number cos(Number);
+ Number cosh(Number);
+ Number acos(Number);
+
+ Number sin(Number);
+ Number sinh(Number);
+ Number asin(Number);
+
+ Number tan(Number);
+ Number tanh(Number);
+ Number atan(Number);
+
+ Number exp(Number);
+ Number log(Number);
+ Number log10(Number);
+ Number sqrt(Number);
+
+ Number atan2(Number, Number);
+ Number pow(Number, Number);
+}
+
+int main()
+{
+ typedef std::valarray<My::Number> Array;
+ Array u(10), v(10);
+ v = +u;
+ v = -u;
+ v = ~u;
+ std::valarray<bool> z = !u;
+
+ v = abs(u);
+
+ v = cos(u);
+ v = cosh(u);
+ v = acos(u);
+
+ v = sin(u);
+ v = sinh(u);
+ v = asin(u);
+
+ v = tan(u);
+ v = tanh(u);
+ v = atan(u);
+
+ v = exp(u);
+ v = log(u);
+ v = log10(u);
+ v = sqrt(u);
+
+ Array w = u + v;
+ w = u - v;
+ w = u * v;
+ w = u / v;
+ w = u % v;
+
+ w = u ^ v;
+ w = u & v;
+ w = u | v;
+
+ w = u << v;
+ w = u >> v;
+
+ z = u == v;
+ z = u != v;
+ z = u < v;
+ z = u <= v;
+ z = u > v;
+ z = u >= v;
+
+ w = atan2(u, v);
+ w = pow(u, v);
+}
--- /dev/null
+// { dg-do run }
+// 2003-02-03 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+// Copyright (C) 2003 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <valarray>
+#include <testsuite_hooks.h>
+
+void test01() // check unary operators
+{
+ bool test __attribute__((unused)) = true;
+ std::valarray<int> u(1);
+ u[0]=1;
+
+ VERIFY( (+u)[0] == +1 );
+ VERIFY( (-u)[0] == -1 );
+ VERIFY( (!u)[0] == !1 );
+ VERIFY( (~u)[0] == ~1 );
+}
+
+void test02() // check binary operators
+{
+ bool test __attribute__((unused)) = true;
+ std::valarray<int> u(1), v(1);
+ u[0]=1;
+ v[0]=3;
+
+ VERIFY( (u+ v)[0] == (1+ 3) );
+ VERIFY( (u- v)[0] == (1- 3) );
+ VERIFY( (u* v)[0] == (1* 3) );
+ VERIFY( (u/ v)[0] == (1/ 3) );
+ VERIFY( (u% v)[0] == (1% 3) );
+ VERIFY( (u^ v)[0] == (1^ 3) );
+ VERIFY( (u& v)[0] == (1& 3) );
+ VERIFY( (u| v)[0] == (1| 3) );
+ VERIFY( (u<<v)[0] == (1<<3) );
+ VERIFY( (u>>v)[0] == (1>>3) );
+ VERIFY( (u&&v)[0] == (1&&3) );
+ VERIFY( (u||v)[0] == (1||3) );
+ VERIFY( (u==v)[0] == (1==3) );
+ VERIFY( (u!=v)[0] == (1!=3) );
+ VERIFY( (u< v)[0] == (1< 3) );
+ VERIFY( (u> v)[0] == (1> 3) );
+ VERIFY( (u<=v)[0] == (1<=3) );
+ VERIFY( (u>=v)[0] == (1>=3) );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers.
+
+#include <valarray>
+
+template class std::valarray<short>;
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2007 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// 6.2.2 Class template array
+
+#include <valarray>
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::valarray<int> test_type;
+ typedef test_type::value_type value_type;
+}
--- /dev/null
+// 2004-01-03 Jerry Quinn <jlquinn@optonline.net>
+
+// Copyright (C) 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// PR 3247
+
+// This is DR-253. Test for accessible assignment-operators.
+#include <valarray>
+#include <testsuite_hooks.h>
+
+bool check_array(std::valarray<double>& a, double b[])
+{
+ for (unsigned int i=0; i < a.size(); i++)
+ if (a[i] != b[i]) return false;
+ return true;
+}
+
+int main()
+{
+ std::valarray<double> val_d(10); // 0 1 2 3 4 5 6 7 8 9
+ std::valarray<double> val_d1(10); // 10 9 8 7 6 5 4 3 2 1
+
+ for (int i=0; i< 10; i++) { val_d[i] = 10; val_d1[i] = i; }
+ std::valarray<double> val_c(val_d);
+ std::valarray<double> val_f(val_d);
+ std::valarray<double> val_g(val_d);
+
+ std::slice slc(1, 3, 3); // 1 4 7
+ val_d[slc] = val_d1[slc];
+
+ double ans1[10] = {10, 1, 10, 10, 4, 10, 10, 7, 10, 10};
+ VERIFY(check_array(val_d, ans1));
+
+ std::valarray<std::size_t> val_size(2);
+ std::valarray<std::size_t> val_stride(2);
+ val_size[0] = 2; val_size[1] = 3;
+ val_stride[0] = 4; val_stride[1] = 1;
+
+ std::gslice gslc(1, val_size, val_stride);
+ val_c[gslc] = val_d1[gslc];
+
+ double ans2[10] = {10, 1, 2, 3, 10, 5, 6, 7, 10, 10};
+ VERIFY(check_array(val_c, ans2));
+
+ std::valarray<bool> val_b(false, 10);
+ val_b[2] = val_b[6] = val_b[9] = true;
+ val_f[val_b] = val_d1[val_b];
+
+ double ans3[10] = {10, 10, 2, 10, 10, 10, 6, 10, 10, 9};
+ VERIFY(check_array(val_f, ans3));
+
+ size_t addr[] = {1, 2, 3, 4, 5};
+ size_t addr1[] = {2, 7, 1, 9, 4};
+ std::valarray<std::size_t> val_indirect(addr, 5);
+ std::valarray<std::size_t> val_indirect1(addr1, 5);
+ val_g[val_indirect] = val_d1[val_indirect1];
+
+ double ans4[10] = {10, 2, 7, 1, 9, 4, 10, 10, 10, 10};
+ VERIFY(check_array(val_g, ans4));
+
+ return 0;
+};
+++ /dev/null
-// 20010518 gdr
-
-// Copyright (C) 2001 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-#include <valarray>
-
-// dg-do compile
-
-template<typename P>
- void copy(P, std::size_t) { }
-
-template<typename T>
- void test(const std::valarray<T>& v)
- {
- copy(&v[0], v.size());
- }
-
-int main()
-{
- std::valarray<double> v(190);
- test(v);
- return 0;
-}
+++ /dev/null
-// 2002-08-02 gdr
-
-// Copyright (C) 2002, 2003 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-// Test name lookup resolutions for standard functions applied to an
-// array expression.
-// { dg-do compile }
-
-#include <valarray>
-
-namespace My
-{
- struct Number
- {
- operator bool() const;
- };
-
- Number operator+(Number);
- Number operator-(Number);
- Number operator~(Number);
-
- bool operator!(Number);
-
- Number operator+(Number, Number);
- Number operator-(Number, Number);
- Number operator*(Number, Number);
- Number operator/(Number, Number);
- Number operator%(Number, Number);
-
- Number operator^(Number, Number);
- Number operator&(Number, Number);
- Number operator|(Number, Number);
-
- Number operator<<(Number, Number);
- Number operator>>(Number, Number);
-
- bool operator==(Number, Number);
- bool operator!=(Number, Number);
- bool operator<(Number, Number);
- bool operator<=(Number, Number);
- bool operator>(Number, Number);
- bool operator>=(Number, Number);
-
- Number abs(Number);
-
- Number cos(Number);
- Number cosh(Number);
- Number acos(Number);
-
- Number sin(Number);
- Number sinh(Number);
- Number asin(Number);
-
- Number tan(Number);
- Number tanh(Number);
- Number atan(Number);
-
- Number exp(Number);
- Number log(Number);
- Number log10(Number);
- Number sqrt(Number);
-
- Number atan2(Number, Number);
- Number pow(Number, Number);
-}
-
-int main()
-{
- typedef std::valarray<My::Number> Array;
- Array u(10), v(10);
- v = +u;
- v = -u;
- v = ~u;
- std::valarray<bool> z = !u;
-
- v = abs(u);
-
- v = cos(u);
- v = cosh(u);
- v = acos(u);
-
- v = sin(u);
- v = sinh(u);
- v = asin(u);
-
- v = tan(u);
- v = tanh(u);
- v = atan(u);
-
- v = exp(u);
- v = log(u);
- v = log10(u);
- v = sqrt(u);
-
- Array w = u + v;
- w = u - v;
- w = u * v;
- w = u / v;
- w = u % v;
-
- w = u ^ v;
- w = u & v;
- w = u | v;
-
- w = u << v;
- w = u >> v;
-
- z = u == v;
- z = u != v;
- z = u < v;
- z = u <= v;
- z = u > v;
- z = u >= v;
-
- w = atan2(u, v);
- w = pow(u, v);
-}
+++ /dev/null
-// { dg-do run }
-// 2003-02-03 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
-
-// Copyright (C) 2003 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-#include <valarray>
-#include <testsuite_hooks.h>
-
-void test01() // check unary operators
-{
- bool test __attribute__((unused)) = true;
- std::valarray<int> u(1);
- u[0]=1;
-
- VERIFY( (+u)[0] == +1 );
- VERIFY( (-u)[0] == -1 );
- VERIFY( (!u)[0] == !1 );
- VERIFY( (~u)[0] == ~1 );
-}
-
-void test02() // check binary operators
-{
- bool test __attribute__((unused)) = true;
- std::valarray<int> u(1), v(1);
- u[0]=1;
- v[0]=3;
-
- VERIFY( (u+ v)[0] == (1+ 3) );
- VERIFY( (u- v)[0] == (1- 3) );
- VERIFY( (u* v)[0] == (1* 3) );
- VERIFY( (u/ v)[0] == (1/ 3) );
- VERIFY( (u% v)[0] == (1% 3) );
- VERIFY( (u^ v)[0] == (1^ 3) );
- VERIFY( (u& v)[0] == (1& 3) );
- VERIFY( (u| v)[0] == (1| 3) );
- VERIFY( (u<<v)[0] == (1<<3) );
- VERIFY( (u>>v)[0] == (1>>3) );
- VERIFY( (u&&v)[0] == (1&&3) );
- VERIFY( (u||v)[0] == (1||3) );
- VERIFY( (u==v)[0] == (1==3) );
- VERIFY( (u!=v)[0] == (1!=3) );
- VERIFY( (u< v)[0] == (1< 3) );
- VERIFY( (u> v)[0] == (1> 3) );
- VERIFY( (u<=v)[0] == (1<=3) );
- VERIFY( (u>=v)[0] == (1>=3) );
-}
-
-int main()
-{
- test01();
- test02();
- return 0;
-}
+++ /dev/null
-// 2004-01-03 Jerry Quinn <jlquinn@optonline.net>
-
-// Copyright (C) 2004 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 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-// PR 3247
-
-// This is DR-253. Test for accessible assignment-operators.
-#include <valarray>
-#include <testsuite_hooks.h>
-
-bool check_array(std::valarray<double>& a, double b[])
-{
- for (unsigned int i=0; i < a.size(); i++)
- if (a[i] != b[i]) return false;
- return true;
-}
-
-int main()
-{
- std::valarray<double> val_d(10); // 0 1 2 3 4 5 6 7 8 9
- std::valarray<double> val_d1(10); // 10 9 8 7 6 5 4 3 2 1
-
- for (int i=0; i< 10; i++) { val_d[i] = 10; val_d1[i] = i; }
- std::valarray<double> val_c(val_d);
- std::valarray<double> val_f(val_d);
- std::valarray<double> val_g(val_d);
-
- std::slice slc(1, 3, 3); // 1 4 7
- val_d[slc] = val_d1[slc];
-
- double ans1[10] = {10, 1, 10, 10, 4, 10, 10, 7, 10, 10};
- VERIFY(check_array(val_d, ans1));
-
- std::valarray<std::size_t> val_size(2);
- std::valarray<std::size_t> val_stride(2);
- val_size[0] = 2; val_size[1] = 3;
- val_stride[0] = 4; val_stride[1] = 1;
-
- std::gslice gslc(1, val_size, val_stride);
- val_c[gslc] = val_d1[gslc];
-
- double ans2[10] = {10, 1, 2, 3, 10, 5, 6, 7, 10, 10};
- VERIFY(check_array(val_c, ans2));
-
- std::valarray<bool> val_b(false, 10);
- val_b[2] = val_b[6] = val_b[9] = true;
- val_f[val_b] = val_d1[val_b];
-
- double ans3[10] = {10, 10, 2, 10, 10, 10, 6, 10, 10, 9};
- VERIFY(check_array(val_f, ans3));
-
- size_t addr[] = {1, 2, 3, 4, 5};
- size_t addr1[] = {2, 7, 1, 9, 4};
- std::valarray<std::size_t> val_indirect(addr, 5);
- std::valarray<std::size_t> val_indirect1(addr1, 5);
- val_g[val_indirect] = val_d1[val_indirect1];
-
- double ans4[10] = {10, 2, 7, 1, 9, 4, 10, 10, 10, 10};
- VERIFY(check_array(val_g, ans4));
-
- return 0;
-};
--- /dev/null
+// 2006-09-24 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 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());
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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();
+ VERIFY( false );
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ // Expected.
+ VERIFY( true );
+ }
+ catch (...)
+ {
+ // Failed.
+ VERIFY( false );
+ }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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();
+ VERIFY( false );
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ // Expected.
+ VERIFY( true );
+ }
+ catch (...)
+ {
+ // Failed.
+ VERIFY( false );
+ }
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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();
+ VERIFY( false );
+ }
+ catch (const std::tr1::bad_weak_ptr&)
+ {
+ // Expected.
+ VERIFY( true );
+ }
+ catch (...)
+ {
+ // Failed.
+ VERIFY( false );
+ }
+
+ return 0;
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 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>;
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
+++ /dev/null
-// 2006-09-24 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 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());
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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();
- VERIFY( false );
- }
- catch (const std::tr1::bad_weak_ptr&)
- {
- // Expected.
- VERIFY( true );
- }
- catch (...)
- {
- // Failed.
- VERIFY( false );
- }
-
- return 0;
-}
-
-int
-main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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();
- VERIFY( false );
- }
- catch (const std::tr1::bad_weak_ptr&)
- {
- // Expected.
- VERIFY( true );
- }
- catch (...)
- {
- // Failed.
- VERIFY( false );
- }
-
- return 0;
-}
-
-int
-main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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();
- VERIFY( false );
- }
- catch (const std::tr1::bad_weak_ptr&)
- {
- // Expected.
- VERIFY( true );
- }
- catch (...)
- {
- // Failed.
- VERIFY( false );
- }
-
- return 0;
-}
-
-
-int
-main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 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>;
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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>
-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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// { dg-do compile }
-
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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-excess-errors "In constructor" }
+++ /dev/null
-// { dg-do compile }
-
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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-excess-errors "candidates are" }
+++ /dev/null
-// { dg-do compile }
-
-// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 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);
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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>
-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;
-}
+++ /dev/null
-// { dg-do compile }
-
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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 }
-// { dg-error "instantiated from" "" { target *-*-* } 0 }
+++ /dev/null
-// 2006-09-24 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 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));
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// { dg-do compile }
-
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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-excess-errors "candidates are" }
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// { 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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();
- 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// { dg-do compile }
-
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 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;
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// { dg-do compile }
-
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// { dg-do compile }
-
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// 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;
-}
+++ /dev/null
-// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 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>;
+++ /dev/null
-// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
-
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* } }
-// { dg-options "-pthreads" { target *-*-solaris* } }
-
-#include <tr1/memory>
-#include <tr1/random>
-#include <vector>
-#include <testsuite_hooks.h>
-#include <iostream>
-
-#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 = *reinterpret_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 = *reinterpret_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;
- int ret = pthread_attr_init(&tattr);
-
- shared_and_weak_pools pools(obj_pool, weak_pool[0]);
- pthread_create(threads, &tattr, thread_hammer_and_kill, reinterpret_cast<void*>(&pools));
- for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++)
- {
- if (pthread_create(&threads[worker], &tattr,
- thread_hammer, reinterpret_cast<void*>(&weak_pool[worker])))
- 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))
- abort();
- }
- obj_pool.clear();
-
- VERIFY( A::counter == 0 );
-
- return 0;
-}
-
-int
-main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
-
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
-// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* } }
-// { dg-options "-pthreads" { target *-*-solaris* } }
-
-#include <tr1/memory>
-#include <tr1/random>
-#include <vector>
-#include <testsuite_hooks.h>
-#include <iostream>
-
-#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 = *reinterpret_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 = *reinterpret_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;
- int ret = pthread_attr_init(&tattr);
-
- shared_and_weak_pools pools(obj_pool, weak_pool[0]);
- pthread_create(threads, &tattr, thread_hammer_and_kill, reinterpret_cast<void*>(&pools));
- for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++)
- {
- if (pthread_create(&threads[worker], &tattr,
- thread_hammer, reinterpret_cast<void*>(&weak_pool[worker])))
- 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))
- abort();
- }
- obj_pool.clear();
-
- VERIFY( A::counter == 0 );
-
- return 0;
-}
-
-int
-main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 2006-09-24 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 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());
-}
+++ /dev/null
-// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 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>;
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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>
+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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// { dg-do compile }
+
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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-excess-errors "In constructor" }
--- /dev/null
+// { dg-do compile }
+
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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-excess-errors "candidates are" }
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 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);
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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>
+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;
+}
--- /dev/null
+// { dg-do compile }
+
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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 }
+// { dg-error "instantiated from" "" { target *-*-* } 0 }
--- /dev/null
+// 2006-09-24 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 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));
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// { dg-do compile }
+
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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-excess-errors "candidates are" }
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// { 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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();
+ 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// { dg-do compile }
+
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 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;
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// { dg-do compile }
+
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// { dg-do compile }
+
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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;
+}
--- /dev/null
+// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 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>;
--- /dev/null
+// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* } }
+// { dg-options "-pthreads" { target *-*-solaris* } }
+
+#include <tr1/memory>
+#include <tr1/random>
+#include <vector>
+#include <testsuite_hooks.h>
+#include <iostream>
+
+#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 = *reinterpret_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 = *reinterpret_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;
+ int ret = pthread_attr_init(&tattr);
+
+ shared_and_weak_pools pools(obj_pool, weak_pool[0]);
+ pthread_create(threads, &tattr, thread_hammer_and_kill, reinterpret_cast<void*>(&pools));
+ for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++)
+ {
+ if (pthread_create(&threads[worker], &tattr,
+ thread_hammer, reinterpret_cast<void*>(&weak_pool[worker])))
+ 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))
+ abort();
+ }
+ obj_pool.clear();
+
+ VERIFY( A::counter == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* } }
+// { dg-options "-pthreads" { target *-*-solaris* } }
+
+#include <tr1/memory>
+#include <tr1/random>
+#include <vector>
+#include <testsuite_hooks.h>
+#include <iostream>
+
+#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 = *reinterpret_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 = *reinterpret_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;
+ int ret = pthread_attr_init(&tattr);
+
+ shared_and_weak_pools pools(obj_pool, weak_pool[0]);
+ pthread_create(threads, &tattr, thread_hammer_and_kill, reinterpret_cast<void*>(&pools));
+ for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++)
+ {
+ if (pthread_create(&threads[worker], &tattr,
+ thread_hammer, reinterpret_cast<void*>(&weak_pool[worker])))
+ 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))
+ abort();
+ }
+ obj_pool.clear();
+
+ VERIFY( A::counter == 0 );
+
+ return 0;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2006-09-24 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 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());
+}
--- /dev/null
+// Copyright (C) 2006 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 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>;