From: Benjamin Kosnik Date: Tue, 20 Feb 2007 19:47:35 +0000 (+0000) Subject: Directory layout flattening. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f05e2819afcf3435618010ee2a79576fd77d00d7;p=gcc.git Directory layout flattening. 2007-02-20 Benjamin Kosnik 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 From-SVN: r122171 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 937d3150cb5..712ad78f04b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,7 +1,182 @@ +2007-02-20 Benjamin Kosnik + + 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 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 @@ -610,7 +785,7 @@ * 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 @@ -891,9 +1066,9 @@ * 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 diff --git a/libstdc++-v3/testsuite/20_util/allocator/1.cc b/libstdc++-v3/testsuite/20_util/allocator/1.cc new file mode 100644 index 00000000000..3d621995b30 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/1.cc @@ -0,0 +1,66 @@ +// 2001-06-14 Benjamin Kosnik + +// 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 +#include +#include +#include + +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 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; +} + diff --git a/libstdc++-v3/testsuite/20_util/allocator/10378.cc b/libstdc++-v3/testsuite/20_util/allocator/10378.cc new file mode 100644 index 00000000000..268ccb22d01 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/10378.cc @@ -0,0 +1,46 @@ +// 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 +#include +#include + +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 uniset; + uniset.push_back(Bob()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/allocator/14176.cc b/libstdc++-v3/testsuite/20_util/allocator/14176.cc new file mode 100644 index 00000000000..340b7b2525d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/14176.cc @@ -0,0 +1,37 @@ +// 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 +#include + +// libstdc++/14176 +void test02() +{ + unsigned int len = 0; + std::allocator a; + int* p = a.allocate(len); + a.deallocate(p, len); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/allocator/8230.cc b/libstdc++-v3/testsuite/20_util/allocator/8230.cc new file mode 100644 index 00000000000..444443fd3af --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/8230.cc @@ -0,0 +1,54 @@ +// 2001-06-14 Benjamin Kosnik + +// 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 +#include +#include + +// libstdc++/8230 +void test02() +{ + bool test __attribute__((unused)) = true; + try + { + std::allocator alloc; + const std::allocator::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; +} diff --git a/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc new file mode 100644 index 00000000000..ed88aefe6c6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc @@ -0,0 +1,34 @@ +// { 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 + +template class std::allocator; diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc new file mode 100644 index 00000000000..f126008bd34 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc @@ -0,0 +1,95 @@ +// 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 +#include + +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_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_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_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; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc new file mode 100644 index 00000000000..7c51d805b66 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc @@ -0,0 +1,85 @@ +// 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 +#include + +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_from_A(new A); + std::auto_ptr B_from_B(new B); + + std::auto_ptr A_from_ptr_A(A_from_A); + std::auto_ptr 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; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc new file mode 100644 index 00000000000..89e23b78d1f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc @@ -0,0 +1,87 @@ +// 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 +#include + +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_from_ptr_A; + std::auto_ptr A_from_ptr_B; + std::auto_ptr A_from_A(new A); + std::auto_ptr 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; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc new file mode 100644 index 00000000000..fcb9b451d77 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc @@ -0,0 +1,45 @@ +// 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 +#include + +// libstdc++/3946 +// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html +struct Base { }; +struct Derived : public Base { }; + +std::auto_ptr +conversiontest08() { return std::auto_ptr(new Derived); } + +void +test08() +{ + std::auto_ptr ptr; + ptr = conversiontest08(); +} + + +int +main() +{ + test08(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc new file mode 100644 index 00000000000..3f8bcd987e4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc @@ -0,0 +1,83 @@ +// 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 +#include + +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_from_A(new A); + std::auto_ptr A_from_B(new B); + std::auto_ptr 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; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc new file mode 100644 index 00000000000..bb27a21ee4c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc @@ -0,0 +1,87 @@ +// 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 +#include + +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 +class pimpl +{ +public: + pimpl() : p_impl(new T) {} +private: + std::auto_ptr p_impl; +}; + +int +test05() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + pimpl(); + pimpl(); + 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; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc new file mode 100644 index 00000000000..c4c995eca9d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc @@ -0,0 +1,91 @@ +// 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 +#include + +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_from_A(new A); + std::auto_ptr 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; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc new file mode 100644 index 00000000000..8e22804aceb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc @@ -0,0 +1,91 @@ +// 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 +#include + +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 +static std::auto_ptr source() +{ + return std::auto_ptr(new T); +} + +template +static void drain(std::auto_ptr) +{} + +int +test07() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + drain(source()); + // The resolution of core issue 84, now a DR, breaks this call. + // drain(source()); + drain(source()); + 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; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc new file mode 100644 index 00000000000..4ae7acfd5c4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc @@ -0,0 +1,50 @@ +// { 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 +#include + +// via Jack Reeves +// libstdc++/3946 +// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html +struct Base { }; +struct Derived : public Base { }; + +std::auto_ptr +foo() { return std::auto_ptr(new Derived); } + +int +test01() +{ + std::auto_ptr 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 } diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 00000000000..e6abacd13b6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,34 @@ +// { 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 + +template class std::auto_ptr; diff --git a/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc b/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc new file mode 100644 index 00000000000..2d374e60fb0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc @@ -0,0 +1,104 @@ +// 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 +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 p1(&s::f_void_void); + mem_fun_t p2(&s::f_int_void); + p1(&a); + p2(&a); + mem_fun1_t q1(&s::f_void_int); + mem_fun1_t 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 ref1(&s::f_void_void); + mem_fun_ref_t ref2(&s::f_int_void); + + ref1(a); + ref2(a); + + mem_fun1_ref_t ref3(&s::f_void_int); + mem_fun1_ref_t 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 p1(&s::f_void_void_const); + const_mem_fun_t p2(&s::f_int_void_const); + p1(&a); + p2(&a); + const_mem_fun1_t q1(&s::f_void_int_const); + const_mem_fun1_t 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 ref1(&s::f_void_void_const); + const_mem_fun_ref_t ref2(&s::f_int_void_const); + + ref1(a); + ref2(a); + + const_mem_fun1_ref_t ref3(&s::f_void_int_const); + const_mem_fun1_ref_t 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); +} diff --git a/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc b/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc new file mode 100644 index 00000000000..210631653c9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc @@ -0,0 +1,50 @@ +// 2001-06-11 Benjamin Kosnik + +// 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 +#include // for_each +#include + +class Elem +{ +public: + void print(int) const { } + void modify(int) { } +}; + +// libstdc++/3113 +void test01() +{ + std::vector 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; +} diff --git a/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc b/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc new file mode 100644 index 00000000000..9ed12fef4e7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc @@ -0,0 +1,53 @@ +// 2001-06-18 Benjamin Kosnik + +// 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 + +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 + 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; +template struct std::not_equal_to; +template struct std::not_equal_to >; + +int main() +{ + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/functional/binders/1.cc b/libstdc++-v3/testsuite/20_util/functional/binders/1.cc deleted file mode 100644 index 2d374e60fb0..00000000000 --- a/libstdc++-v3/testsuite/20_util/functional/binders/1.cc +++ /dev/null @@ -1,104 +0,0 @@ -// 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 -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 p1(&s::f_void_void); - mem_fun_t p2(&s::f_int_void); - p1(&a); - p2(&a); - mem_fun1_t q1(&s::f_void_int); - mem_fun1_t 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 ref1(&s::f_void_void); - mem_fun_ref_t ref2(&s::f_int_void); - - ref1(a); - ref2(a); - - mem_fun1_ref_t ref3(&s::f_void_int); - mem_fun1_ref_t 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 p1(&s::f_void_void_const); - const_mem_fun_t p2(&s::f_int_void_const); - p1(&a); - p2(&a); - const_mem_fun1_t q1(&s::f_void_int_const); - const_mem_fun1_t 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 ref1(&s::f_void_void_const); - const_mem_fun_ref_t ref2(&s::f_int_void_const); - - ref1(a); - ref2(a); - - const_mem_fun1_ref_t ref3(&s::f_void_int_const); - const_mem_fun1_ref_t 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); -} diff --git a/libstdc++-v3/testsuite/20_util/functional/binders/3113.cc b/libstdc++-v3/testsuite/20_util/functional/binders/3113.cc deleted file mode 100644 index 210631653c9..00000000000 --- a/libstdc++-v3/testsuite/20_util/functional/binders/3113.cc +++ /dev/null @@ -1,50 +0,0 @@ -// 2001-06-11 Benjamin Kosnik - -// 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 -#include // for_each -#include - -class Elem -{ -public: - void print(int) const { } - void modify(int) { } -}; - -// libstdc++/3113 -void test01() -{ - std::vector 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; -} diff --git a/libstdc++-v3/testsuite/20_util/functional/comparisons.cc b/libstdc++-v3/testsuite/20_util/functional/comparisons.cc deleted file mode 100644 index 9ed12fef4e7..00000000000 --- a/libstdc++-v3/testsuite/20_util/functional/comparisons.cc +++ /dev/null @@ -1,53 +0,0 @@ -// 2001-06-18 Benjamin Kosnik - -// 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 - -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 - 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; -template struct std::not_equal_to; -template struct std::not_equal_to >; - -int main() -{ - return 0; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/16505.cc b/libstdc++-v3/testsuite/20_util/memory/16505.cc deleted file mode 100644 index b20c0496ee8..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/16505.cc +++ /dev/null @@ -1,31 +0,0 @@ -// 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 - -// libstdc++/16505 - -struct S { }; - -template - void - std::uninitialized_fill_n(S*, int, const S&); diff --git a/libstdc++-v3/testsuite/20_util/memory/allocator/1.cc b/libstdc++-v3/testsuite/20_util/memory/allocator/1.cc deleted file mode 100644 index 3d621995b30..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/allocator/1.cc +++ /dev/null @@ -1,66 +0,0 @@ -// 2001-06-14 Benjamin Kosnik - -// 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 -#include -#include -#include - -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 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; -} - diff --git a/libstdc++-v3/testsuite/20_util/memory/allocator/10378.cc b/libstdc++-v3/testsuite/20_util/memory/allocator/10378.cc deleted file mode 100644 index 268ccb22d01..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/allocator/10378.cc +++ /dev/null @@ -1,46 +0,0 @@ -// 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 -#include -#include - -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 uniset; - uniset.push_back(Bob()); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/allocator/14176.cc b/libstdc++-v3/testsuite/20_util/memory/allocator/14176.cc deleted file mode 100644 index 340b7b2525d..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/allocator/14176.cc +++ /dev/null @@ -1,37 +0,0 @@ -// 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 -#include - -// libstdc++/14176 -void test02() -{ - unsigned int len = 0; - std::allocator a; - int* p = a.allocate(len); - a.deallocate(p, len); -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/allocator/8230.cc b/libstdc++-v3/testsuite/20_util/memory/allocator/8230.cc deleted file mode 100644 index 444443fd3af..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/allocator/8230.cc +++ /dev/null @@ -1,54 +0,0 @@ -// 2001-06-14 Benjamin Kosnik - -// 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 -#include -#include - -// libstdc++/8230 -void test02() -{ - bool test __attribute__((unused)) = true; - try - { - std::allocator alloc; - const std::allocator::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; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/allocator/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/memory/allocator/requirements/explicit_instantiation/1.cc deleted file mode 100644 index ed88aefe6c6..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/allocator/requirements/explicit_instantiation/1.cc +++ /dev/null @@ -1,34 +0,0 @@ -// { 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 - -template class std::allocator; diff --git a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/1.cc b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/1.cc deleted file mode 100644 index f126008bd34..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/1.cc +++ /dev/null @@ -1,95 +0,0 @@ -// 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 -#include - -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_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_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_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; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/2.cc b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/2.cc deleted file mode 100644 index 7c51d805b66..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/2.cc +++ /dev/null @@ -1,85 +0,0 @@ -// 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 -#include - -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_from_A(new A); - std::auto_ptr B_from_B(new B); - - std::auto_ptr A_from_ptr_A(A_from_A); - std::auto_ptr 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; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/3.cc b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/3.cc deleted file mode 100644 index 89e23b78d1f..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/3.cc +++ /dev/null @@ -1,87 +0,0 @@ -// 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 -#include - -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_from_ptr_A; - std::auto_ptr A_from_ptr_B; - std::auto_ptr A_from_A(new A); - std::auto_ptr 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; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/3946.cc b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/3946.cc deleted file mode 100644 index fcb9b451d77..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/3946.cc +++ /dev/null @@ -1,45 +0,0 @@ -// 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 -#include - -// libstdc++/3946 -// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html -struct Base { }; -struct Derived : public Base { }; - -std::auto_ptr -conversiontest08() { return std::auto_ptr(new Derived); } - -void -test08() -{ - std::auto_ptr ptr; - ptr = conversiontest08(); -} - - -int -main() -{ - test08(); - return 0; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/4.cc b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/4.cc deleted file mode 100644 index 3f8bcd987e4..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/4.cc +++ /dev/null @@ -1,83 +0,0 @@ -// 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 -#include - -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_from_A(new A); - std::auto_ptr A_from_B(new B); - std::auto_ptr 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; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/5.cc b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/5.cc deleted file mode 100644 index bb27a21ee4c..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/5.cc +++ /dev/null @@ -1,87 +0,0 @@ -// 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 -#include - -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 -class pimpl -{ -public: - pimpl() : p_impl(new T) {} -private: - std::auto_ptr p_impl; -}; - -int -test05() -{ - bool test __attribute__((unused)) = true; - reset_count_struct __attribute__((unused)) reset; - - pimpl(); - pimpl(); - 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; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/6.cc b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/6.cc deleted file mode 100644 index c4c995eca9d..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/6.cc +++ /dev/null @@ -1,91 +0,0 @@ -// 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 -#include - -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_from_A(new A); - std::auto_ptr 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; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/7.cc b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/7.cc deleted file mode 100644 index 8e22804aceb..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/7.cc +++ /dev/null @@ -1,91 +0,0 @@ -// 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 -#include - -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 -static std::auto_ptr source() -{ - return std::auto_ptr(new T); -} - -template -static void drain(std::auto_ptr) -{} - -int -test07() -{ - bool test __attribute__((unused)) = true; - reset_count_struct __attribute__((unused)) reset; - - drain(source()); - // The resolution of core issue 84, now a DR, breaks this call. - // drain(source()); - drain(source()); - 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; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/assign_neg.cc b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/assign_neg.cc deleted file mode 100644 index 4ae7acfd5c4..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/assign_neg.cc +++ /dev/null @@ -1,50 +0,0 @@ -// { 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 -#include - -// via Jack Reeves -// libstdc++/3946 -// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html -struct Base { }; -struct Derived : public Base { }; - -std::auto_ptr -foo() { return std::auto_ptr(new Derived); } - -int -test01() -{ - std::auto_ptr 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 } diff --git a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/requirements/explicit_instantiation/1.cc deleted file mode 100644 index e6abacd13b6..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/requirements/explicit_instantiation/1.cc +++ /dev/null @@ -1,34 +0,0 @@ -// { 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 - -template class std::auto_ptr; diff --git a/libstdc++-v3/testsuite/20_util/memory/raw_storage_iterator/requirements/base_classes.cc b/libstdc++-v3/testsuite/20_util/memory/raw_storage_iterator/requirements/base_classes.cc deleted file mode 100644 index bc2793f3d97..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/raw_storage_iterator/requirements/base_classes.cc +++ /dev/null @@ -1,37 +0,0 @@ -// { dg-do compile } - -// 2001-06-18 Benjamin Kosnik - -// 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 - -void test01() -{ - using namespace std; - - // Check for required base class. - long l; - typedef raw_storage_iterator test_iterator; - typedef iterator base_iterator; - test_iterator rs_it(&l); - base_iterator* base __attribute__((unused)) = &rs_it; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/raw_storage_iterator/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/memory/raw_storage_iterator/requirements/explicit_instantiation/1.cc deleted file mode 100644 index 41023b6bcd2..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/raw_storage_iterator/requirements/explicit_instantiation/1.cc +++ /dev/null @@ -1,34 +0,0 @@ -// { 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 - -template class std::raw_storage_iterator; diff --git a/libstdc++-v3/testsuite/20_util/memory/raw_storage_iterator/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/memory/raw_storage_iterator/requirements/typedefs.cc deleted file mode 100644 index 4a51c4c6fd3..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/raw_storage_iterator/requirements/typedefs.cc +++ /dev/null @@ -1,38 +0,0 @@ -// { dg-do compile } -// 2001-06-18 Benjamin Kosnik - -// 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 - -void test01() -{ - using namespace std; - - // Check for required typedefs - long l; - typedef raw_storage_iterator 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; -} diff --git a/libstdc++-v3/testsuite/20_util/memory/temporary_buffer.cc b/libstdc++-v3/testsuite/20_util/memory/temporary_buffer.cc deleted file mode 100644 index aee343a586e..00000000000 --- a/libstdc++-v3/testsuite/20_util/memory/temporary_buffer.cc +++ /dev/null @@ -1,50 +0,0 @@ -// 2002-01-24 Phil Edwards - -// 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 -#include - -struct junk { char j[12]; }; - -int main(void) -{ - bool test __attribute__((unused)) = true; - - std::pair results = std::get_temporary_buffer(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; -} diff --git a/libstdc++-v3/testsuite/20_util/pair/1.cc b/libstdc++-v3/testsuite/20_util/pair/1.cc new file mode 100644 index 00000000000..9b7f5551b9a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/1.cc @@ -0,0 +1,79 @@ +// 2001-06-18 Benjamin Kosnik + +// 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 +#include + +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 + 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 p_bl_1(true, 433); + std::pair p_bl_2 = std::make_pair(true, 433); + VERIFY( p_bl_1 == p_bl_2 ); + VERIFY( !(p_bl_1 < p_bl_2) ); + + std::pair p_sf_1("total enlightenment", 433.00); + std::pair 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 p_sg_1("enlightenment", gnu_obj(5)); + std::pair 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_obj> p_st_1(gnu_t(false), gnu_obj(5)); + std::pair, gnu_obj> p_st_2 = std::make_pair(gnu_t(false), + gnu_obj(5)); + VERIFY( p_st_1 == p_st_2 ); + VERIFY( !(p_st_1 < p_st_2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/2.cc b/libstdc++-v3/testsuite/20_util/pair/2.cc new file mode 100644 index 00000000000..fd5f8ad5d41 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/2.cc @@ -0,0 +1,60 @@ +// 2001-06-18 Benjamin Kosnik + +// 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 +#include + +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 + 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 p_bb_1(true, false); + std::pair 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; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/3.cc b/libstdc++-v3/testsuite/20_util/pair/3.cc new file mode 100644 index 00000000000..f861134d2b8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/3.cc @@ -0,0 +1,79 @@ +// 2001-06-18 Benjamin Kosnik + +// 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 +#include + +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 + 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 p_bl_1(true, 433); + const std::pair 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 p_sf_1("total enlightenment", 433.00); + const std::pair 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 p_sg_1("enlightenment", gnu_obj(5)); + const std::pair 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_obj> p_st_1(gnu_t(false), gnu_obj(5)); + const std::pair, gnu_obj> p_st_2 = + std::make_pair(gnu_t(false), gnu_obj(5)); + VERIFY( p_st_1 == p_st_2 ); + VERIFY( !(p_st_1 < p_st_2) ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/4.cc b/libstdc++-v3/testsuite/20_util/pair/4.cc new file mode 100644 index 00000000000..086cc9eb6c3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/4.cc @@ -0,0 +1,67 @@ +// 2001-06-18 Benjamin Kosnik + +// 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 +#include + +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 + 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 p_sg_1("enlightenment", obj1); + const std::pair 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& tmpl1 = gnu_t(false); + const std::pair, gnu_obj> p_st_1(tmpl1, obj1); + const std::pair, 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; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc new file mode 100644 index 00000000000..3d55f629de2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc @@ -0,0 +1,34 @@ +// { 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 + +template class std::pair; diff --git a/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc new file mode 100644 index 00000000000..bc2793f3d97 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2001-06-18 Benjamin Kosnik + +// 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 + +void test01() +{ + using namespace std; + + // Check for required base class. + long l; + typedef raw_storage_iterator test_iterator; + typedef iterator base_iterator; + test_iterator rs_it(&l); + base_iterator* base __attribute__((unused)) = &rs_it; +} diff --git a/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc new file mode 100644 index 00000000000..41023b6bcd2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc @@ -0,0 +1,34 @@ +// { 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 + +template class std::raw_storage_iterator; diff --git a/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc new file mode 100644 index 00000000000..4a51c4c6fd3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc @@ -0,0 +1,38 @@ +// { dg-do compile } +// 2001-06-18 Benjamin Kosnik + +// 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 + +void test01() +{ + using namespace std; + + // Check for required typedefs + long l; + typedef raw_storage_iterator 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; +} diff --git a/libstdc++-v3/testsuite/20_util/rel_ops.cc b/libstdc++-v3/testsuite/20_util/rel_ops.cc new file mode 100644 index 00000000000..e2ac57d728a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/rel_ops.cc @@ -0,0 +1,46 @@ +// 2002-04-13 Paolo Carlini + +// 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 +#include + +using namespace std::rel_ops; + +// libstdc++/3628 +void test01() +{ + std::vector v; + std::vector::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; +} + diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/16505.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/16505.cc new file mode 100644 index 00000000000..b20c0496ee8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/16505.cc @@ -0,0 +1,31 @@ +// 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 + +// libstdc++/16505 + +struct S { }; + +template + void + std::uninitialized_fill_n(S*, int, const S&); diff --git a/libstdc++-v3/testsuite/20_util/temporary_buffer.cc b/libstdc++-v3/testsuite/20_util/temporary_buffer.cc new file mode 100644 index 00000000000..aee343a586e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/temporary_buffer.cc @@ -0,0 +1,50 @@ +// 2002-01-24 Phil Edwards + +// 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 +#include + +struct junk { char j[12]; }; + +int main(void) +{ + bool test __attribute__((unused)) = true; + + std::pair results = std::get_temporary_buffer(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; +} diff --git a/libstdc++-v3/testsuite/20_util/utility/pair/1.cc b/libstdc++-v3/testsuite/20_util/utility/pair/1.cc deleted file mode 100644 index 9b7f5551b9a..00000000000 --- a/libstdc++-v3/testsuite/20_util/utility/pair/1.cc +++ /dev/null @@ -1,79 +0,0 @@ -// 2001-06-18 Benjamin Kosnik - -// 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 -#include - -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 - 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 p_bl_1(true, 433); - std::pair p_bl_2 = std::make_pair(true, 433); - VERIFY( p_bl_1 == p_bl_2 ); - VERIFY( !(p_bl_1 < p_bl_2) ); - - std::pair p_sf_1("total enlightenment", 433.00); - std::pair 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 p_sg_1("enlightenment", gnu_obj(5)); - std::pair 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_obj> p_st_1(gnu_t(false), gnu_obj(5)); - std::pair, gnu_obj> p_st_2 = std::make_pair(gnu_t(false), - gnu_obj(5)); - VERIFY( p_st_1 == p_st_2 ); - VERIFY( !(p_st_1 < p_st_2) ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/20_util/utility/pair/2.cc b/libstdc++-v3/testsuite/20_util/utility/pair/2.cc deleted file mode 100644 index fd5f8ad5d41..00000000000 --- a/libstdc++-v3/testsuite/20_util/utility/pair/2.cc +++ /dev/null @@ -1,60 +0,0 @@ -// 2001-06-18 Benjamin Kosnik - -// 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 -#include - -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 - 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 p_bb_1(true, false); - std::pair 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; -} diff --git a/libstdc++-v3/testsuite/20_util/utility/pair/3.cc b/libstdc++-v3/testsuite/20_util/utility/pair/3.cc deleted file mode 100644 index f861134d2b8..00000000000 --- a/libstdc++-v3/testsuite/20_util/utility/pair/3.cc +++ /dev/null @@ -1,79 +0,0 @@ -// 2001-06-18 Benjamin Kosnik - -// 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 -#include - -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 - 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 p_bl_1(true, 433); - const std::pair 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 p_sf_1("total enlightenment", 433.00); - const std::pair 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 p_sg_1("enlightenment", gnu_obj(5)); - const std::pair 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_obj> p_st_1(gnu_t(false), gnu_obj(5)); - const std::pair, gnu_obj> p_st_2 = - std::make_pair(gnu_t(false), gnu_obj(5)); - VERIFY( p_st_1 == p_st_2 ); - VERIFY( !(p_st_1 < p_st_2) ); -} - -int main() -{ - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/20_util/utility/pair/4.cc b/libstdc++-v3/testsuite/20_util/utility/pair/4.cc deleted file mode 100644 index 086cc9eb6c3..00000000000 --- a/libstdc++-v3/testsuite/20_util/utility/pair/4.cc +++ /dev/null @@ -1,67 +0,0 @@ -// 2001-06-18 Benjamin Kosnik - -// 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 -#include - -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 - 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 p_sg_1("enlightenment", obj1); - const std::pair 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& tmpl1 = gnu_t(false); - const std::pair, gnu_obj> p_st_1(tmpl1, obj1); - const std::pair, 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; -} diff --git a/libstdc++-v3/testsuite/20_util/utility/pair/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/utility/pair/requirements/explicit_instantiation/1.cc deleted file mode 100644 index 3d55f629de2..00000000000 --- a/libstdc++-v3/testsuite/20_util/utility/pair/requirements/explicit_instantiation/1.cc +++ /dev/null @@ -1,34 +0,0 @@ -// { 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 - -template class std::pair; diff --git a/libstdc++-v3/testsuite/20_util/utility/rel_ops.cc b/libstdc++-v3/testsuite/20_util/utility/rel_ops.cc deleted file mode 100644 index e2ac57d728a..00000000000 --- a/libstdc++-v3/testsuite/20_util/utility/rel_ops.cc +++ /dev/null @@ -1,46 +0,0 @@ -// 2002-04-13 Paolo Carlini - -// 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 -#include - -using namespace std::rel_ops; - -// libstdc++/3628 -void test01() -{ - std::vector v; - std::vector::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; -} - diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/27867.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/27867.cc deleted file mode 100644 index 7c208f4b100..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/27867.cc +++ /dev/null @@ -1,53 +0,0 @@ -// 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 -#include - -// libstdc++/27867 -void test01() -{ - bool test __attribute__((unused)) = true; - - std::valarray v1(100, 1); - std::valarray v2(100, 1); - std::valarray v3(true, 1); - - std::valarray resl(1); - resl = ((v1 == v2) == v3); - VERIFY( resl[0] == true ); - - std::valarray resr(1); - resr = (v3 == (v1 == v2)); - VERIFY( resr[0] == true ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/28277.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/28277.cc deleted file mode 100644 index 52f4c714085..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/28277.cc +++ /dev/null @@ -1,44 +0,0 @@ -// 2006-07-15 Paolo Carlini - -// 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 -#include - -// libstdc++/28277 -void test01() -{ - bool test __attribute__((unused)) = true; - - const std::valarray v1(1, 5000000); - - const std::valarray v2 = v1.shift(1); - VERIFY( v2.size() == v1.size() ); - VERIFY( v2[v1.size() - 1] == 0 ); - - const std::valarray v3 = v2.cshift(-1); - VERIFY( v3.size() == v2.size() ); - VERIFY( v3[0] == 0 ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/30416.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/30416.cc deleted file mode 100644 index c51329221d5..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/30416.cc +++ /dev/null @@ -1,190 +0,0 @@ -// 2007-01-11 Paolo Carlini - -// 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 -#include - -bool -comp_vala(const std::valarray& v1, const std::valarray& 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& 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 v1; - valarray v1_ris(v1.shift(0)); - VERIFY( comp_vala(v1, v1_ris) ); - - valarray v2; - valarray v2_ris(v2.shift(10)); - VERIFY( comp_vala(v2, v2_ris) ); - - valarray v3; - valarray v3_ris(v3.shift(-10)); - VERIFY( comp_vala(v3, v3_ris) ); - - valarray v4(10); - valarray v4_ris(v4.shift(0)); - VERIFY( comp_vala(v4, v4_ris) ); - - valarray v5(10); - init_vala(v5, 0, 9, 1); - valarray v5_ref(10); - - valarray v5_ris(v5.shift(16)); - VERIFY( comp_vala(v5_ris, v5_ref) ); - - valarray v6(10); - init_vala(v6, 0, 9, 1); - valarray v6_ref(10); - - valarray v6_ris(v6.shift(-16)); - VERIFY( comp_vala(v6_ris, v6_ref) ); - - valarray v7(10); - init_vala(v7, 0, 9, 1); - valarray v7_ref(10); - - valarray v7_ris(v7.shift(10)); - VERIFY( comp_vala(v7_ris, v7_ref) ); - - valarray v8(10); - init_vala(v8, 0, 9, 1); - valarray v8_ref(10); - - valarray v8_ris(v8.shift(-10)); - VERIFY( comp_vala(v8_ris, v8_ref) ); - - valarray v9(10); - init_vala(v9, 0, 9, 1); - valarray v9_ref(10); - init_vala(v9_ref, 0, 3, 7); - - valarray v9_ris(v9.shift(6)); - VERIFY( comp_vala(v9_ris, v9_ref) ); - - valarray v10(10); - init_vala(v10, 0, 9, 1); - valarray v10_ref(10); - init_vala(v10_ref, 6, 9, 1); - - valarray v10_ris(v10.shift(-6)); - VERIFY( comp_vala(v10_ris, v10_ref) ); - - // cshift - valarray v11; - valarray v11_ris(v11.cshift(0)); - VERIFY( comp_vala(v11, v11_ris) ); - - valarray v12; - valarray v12_ris(v12.cshift(10)); - VERIFY( comp_vala(v12, v12_ris) ); - - valarray v13; - valarray v13_ris(v13.cshift(-10)); - VERIFY( comp_vala(v13, v13_ris) ); - - valarray v14(10); - valarray v14_ris(v14.cshift(0)); - VERIFY( comp_vala(v14, v14_ris) ); - - valarray v15(10); - init_vala(v15, 0, 9, 1); - valarray v15_ref(10); - init_vala(v15_ref, 0, 3, 7); - init_vala(v15_ref, 4, 9, 1); - - valarray v15_ris(v15.cshift(16)); - VERIFY( comp_vala(v15_ris, v15_ref) ); - - valarray v16(10); - init_vala(v16, 0, 9, 1); - valarray v16_ref(10); - init_vala(v16_ref, 0, 5, 5); - init_vala(v16_ref, 6, 9, 1); - - valarray v16_ris(v16.cshift(-16)); - VERIFY( comp_vala(v16_ris, v16_ref) ); - - valarray v17(10); - init_vala(v17, 0, 9, 1); - - valarray v17_ris(v15.cshift(10)); - VERIFY( comp_vala(v17, v17_ris) ); - - valarray v18(10); - init_vala(v18, 0, 9, 1); - - valarray v18_ris(v18.cshift(-10)); - VERIFY( comp_vala(v18, v18_ris) ); - - valarray v19(10); - init_vala(v19, 0, 9, 1); - valarray v19_ref(10); - init_vala(v19_ref, 0, 3, 7); - init_vala(v19_ref, 4, 9, 1); - - valarray v19_ris(v15.cshift(6)); - VERIFY( comp_vala(v19_ris, v19_ref) ); - - valarray v20(10); - init_vala(v20, 0, 9, 1); - valarray v20_ref(10); - init_vala(v20_ref, 0, 5, 5); - init_vala(v20_ref, 6, 9, 1); - - valarray v20_ris(v20.cshift(-6)); - VERIFY( comp_vala(v20_ris, v20_ref) ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/binary_closure.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/binary_closure.cc deleted file mode 100644 index 7dbcfbd5228..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/binary_closure.cc +++ /dev/null @@ -1,37 +0,0 @@ -// 19990805 gdr -// -// XXX: to impove later. -// Origin: Andreas Amann -// CXXFLAGS: -g - -#include -#include - - -int main() -{ - std::valarray 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; -} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/dr543.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/dr543.cc deleted file mode 100644 index 9afa93a4b83..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/dr543.cc +++ /dev/null @@ -1,40 +0,0 @@ -// 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 -#include - -// DR 543. valarray slice default constructor -void test01() -{ - bool test __attribute__((unused)) = true; - - std::valarray v1(10); - std::valarray v2 = v1[std::slice()]; - VERIFY( v2.size() == 0 ); - - std::valarray v3(10); - std::valarray v4 = v3[std::gslice()]; - VERIFY( v4.size() == 0 ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array/array_assignment.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array/array_assignment.cc new file mode 100644 index 00000000000..34888be44e9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array/array_assignment.cc @@ -0,0 +1,51 @@ +// 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 +#include + +int main() +{ + bool test __attribute__((unused)) = true; + using std::valarray; + using std::slice; + valarray 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 t = v[slice(0, 10, 1)]; + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..09dfed62745 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array/requirements/explicit_instantiation.cc @@ -0,0 +1,34 @@ +// { 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 + +template class std::slice_array; diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array/requirements/typedefs.cc new file mode 100644 index 00000000000..15295511a1a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array/requirements/typedefs.cc @@ -0,0 +1,39 @@ +// { 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 + +void test01() +{ + // Check for required typedefs + typedef std::slice_array test_type; + typedef test_type::value_type value_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array_assignment.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array_assignment.cc deleted file mode 100644 index 34888be44e9..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/slice_array_assignment.cc +++ /dev/null @@ -1,51 +0,0 @@ -// 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 -#include - -int main() -{ - bool test __attribute__((unused)) = true; - using std::valarray; - using std::slice; - valarray 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 t = v[slice(0, 10, 1)]; - - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray.cc deleted file mode 100644 index 3c206e354f5..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray.cc +++ /dev/null @@ -1,43 +0,0 @@ -// 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 - -int main() -{ - // 01: instantiation - std::valarray a(20); - - // 02: algo - using std::valarray; - valarray b, c; - double m __attribute__((unused)) = std::abs(b - c).max(); - - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/27867.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/27867.cc new file mode 100644 index 00000000000..7c208f4b100 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/27867.cc @@ -0,0 +1,53 @@ +// 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 +#include + +// libstdc++/27867 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::valarray v1(100, 1); + std::valarray v2(100, 1); + std::valarray v3(true, 1); + + std::valarray resl(1); + resl = ((v1 == v2) == v3); + VERIFY( resl[0] == true ); + + std::valarray resr(1); + resr = (v3 == (v1 == v2)); + VERIFY( resr[0] == true ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/28277.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/28277.cc new file mode 100644 index 00000000000..52f4c714085 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/28277.cc @@ -0,0 +1,44 @@ +// 2006-07-15 Paolo Carlini + +// 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 +#include + +// libstdc++/28277 +void test01() +{ + bool test __attribute__((unused)) = true; + + const std::valarray v1(1, 5000000); + + const std::valarray v2 = v1.shift(1); + VERIFY( v2.size() == v1.size() ); + VERIFY( v2[v1.size() - 1] == 0 ); + + const std::valarray v3 = v2.cshift(-1); + VERIFY( v3.size() == v2.size() ); + VERIFY( v3[0] == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/30416.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/30416.cc new file mode 100644 index 00000000000..c51329221d5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/30416.cc @@ -0,0 +1,190 @@ +// 2007-01-11 Paolo Carlini + +// 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 +#include + +bool +comp_vala(const std::valarray& v1, const std::valarray& 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& 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 v1; + valarray v1_ris(v1.shift(0)); + VERIFY( comp_vala(v1, v1_ris) ); + + valarray v2; + valarray v2_ris(v2.shift(10)); + VERIFY( comp_vala(v2, v2_ris) ); + + valarray v3; + valarray v3_ris(v3.shift(-10)); + VERIFY( comp_vala(v3, v3_ris) ); + + valarray v4(10); + valarray v4_ris(v4.shift(0)); + VERIFY( comp_vala(v4, v4_ris) ); + + valarray v5(10); + init_vala(v5, 0, 9, 1); + valarray v5_ref(10); + + valarray v5_ris(v5.shift(16)); + VERIFY( comp_vala(v5_ris, v5_ref) ); + + valarray v6(10); + init_vala(v6, 0, 9, 1); + valarray v6_ref(10); + + valarray v6_ris(v6.shift(-16)); + VERIFY( comp_vala(v6_ris, v6_ref) ); + + valarray v7(10); + init_vala(v7, 0, 9, 1); + valarray v7_ref(10); + + valarray v7_ris(v7.shift(10)); + VERIFY( comp_vala(v7_ris, v7_ref) ); + + valarray v8(10); + init_vala(v8, 0, 9, 1); + valarray v8_ref(10); + + valarray v8_ris(v8.shift(-10)); + VERIFY( comp_vala(v8_ris, v8_ref) ); + + valarray v9(10); + init_vala(v9, 0, 9, 1); + valarray v9_ref(10); + init_vala(v9_ref, 0, 3, 7); + + valarray v9_ris(v9.shift(6)); + VERIFY( comp_vala(v9_ris, v9_ref) ); + + valarray v10(10); + init_vala(v10, 0, 9, 1); + valarray v10_ref(10); + init_vala(v10_ref, 6, 9, 1); + + valarray v10_ris(v10.shift(-6)); + VERIFY( comp_vala(v10_ris, v10_ref) ); + + // cshift + valarray v11; + valarray v11_ris(v11.cshift(0)); + VERIFY( comp_vala(v11, v11_ris) ); + + valarray v12; + valarray v12_ris(v12.cshift(10)); + VERIFY( comp_vala(v12, v12_ris) ); + + valarray v13; + valarray v13_ris(v13.cshift(-10)); + VERIFY( comp_vala(v13, v13_ris) ); + + valarray v14(10); + valarray v14_ris(v14.cshift(0)); + VERIFY( comp_vala(v14, v14_ris) ); + + valarray v15(10); + init_vala(v15, 0, 9, 1); + valarray v15_ref(10); + init_vala(v15_ref, 0, 3, 7); + init_vala(v15_ref, 4, 9, 1); + + valarray v15_ris(v15.cshift(16)); + VERIFY( comp_vala(v15_ris, v15_ref) ); + + valarray v16(10); + init_vala(v16, 0, 9, 1); + valarray v16_ref(10); + init_vala(v16_ref, 0, 5, 5); + init_vala(v16_ref, 6, 9, 1); + + valarray v16_ris(v16.cshift(-16)); + VERIFY( comp_vala(v16_ris, v16_ref) ); + + valarray v17(10); + init_vala(v17, 0, 9, 1); + + valarray v17_ris(v15.cshift(10)); + VERIFY( comp_vala(v17, v17_ris) ); + + valarray v18(10); + init_vala(v18, 0, 9, 1); + + valarray v18_ris(v18.cshift(-10)); + VERIFY( comp_vala(v18, v18_ris) ); + + valarray v19(10); + init_vala(v19, 0, 9, 1); + valarray v19_ref(10); + init_vala(v19_ref, 0, 3, 7); + init_vala(v19_ref, 4, 9, 1); + + valarray v19_ris(v15.cshift(6)); + VERIFY( comp_vala(v19_ris, v19_ref) ); + + valarray v20(10); + init_vala(v20, 0, 9, 1); + valarray v20_ref(10); + init_vala(v20_ref, 0, 5, 5); + init_vala(v20_ref, 6, 9, 1); + + valarray v20_ris(v20.cshift(-6)); + VERIFY( comp_vala(v20_ris, v20_ref) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/algo.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/algo.cc new file mode 100644 index 00000000000..a69ce65e079 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/algo.cc @@ -0,0 +1,40 @@ +// 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 + +int main() +{ + // 02: algo + using std::valarray; + valarray b, c; + double m __attribute__((unused)) = std::abs(b - c).max(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/binary_closure.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/binary_closure.cc new file mode 100644 index 00000000000..7dbcfbd5228 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/binary_closure.cc @@ -0,0 +1,37 @@ +// 19990805 gdr +// +// XXX: to impove later. +// Origin: Andreas Amann +// CXXFLAGS: -g + +#include +#include + + +int main() +{ + std::valarray 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; +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/const_bracket.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/const_bracket.cc new file mode 100644 index 00000000000..512cbafd3ce --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/const_bracket.cc @@ -0,0 +1,48 @@ +// 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 + +// dg-do compile + +template + void copy(P, std::size_t) { } + +template + void test(const std::valarray& v) + { + copy(&v[0], v.size()); + } + +int main() +{ + std::valarray v(190); + test(v); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/dr543.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/dr543.cc new file mode 100644 index 00000000000..9afa93a4b83 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/dr543.cc @@ -0,0 +1,40 @@ +// 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 +#include + +// DR 543. valarray slice default constructor +void test01() +{ + bool test __attribute__((unused)) = true; + + std::valarray v1(10); + std::valarray v2 = v1[std::slice()]; + VERIFY( v2.size() == 0 ); + + std::valarray v3(10); + std::valarray v4 = v3[std::gslice()]; + VERIFY( v4.size() == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/name_lookup.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/name_lookup.cc new file mode 100644 index 00000000000..735f65f5df7 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/name_lookup.cc @@ -0,0 +1,142 @@ +// 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 + +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 Array; + Array u(10), v(10); + v = +u; + v = -u; + v = ~u; + std::valarray 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); +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/operators.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/operators.cc new file mode 100644 index 00000000000..70ad0b0e788 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/operators.cc @@ -0,0 +1,69 @@ +// { dg-do run } +// 2003-02-03 Volker Reichelt + +// 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 +#include + +void test01() // check unary operators +{ + bool test __attribute__((unused)) = true; + std::valarray 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 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) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..d4d5e283048 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/requirements/explicit_instantiation.cc @@ -0,0 +1,34 @@ +// { 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 + +template class std::valarray; diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/requirements/typedefs.cc new file mode 100644 index 00000000000..a6f28dc41a6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/requirements/typedefs.cc @@ -0,0 +1,39 @@ +// { 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 + +void test01() +{ + // Check for required typedefs + typedef std::valarray test_type; + typedef test_type::value_type value_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/subset_assignment.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/subset_assignment.cc new file mode 100644 index 00000000000..4ce22afb31a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray/subset_assignment.cc @@ -0,0 +1,87 @@ +// 2004-01-03 Jerry Quinn + +// 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 +#include + +bool check_array(std::valarray& 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 val_d(10); // 0 1 2 3 4 5 6 7 8 9 + std::valarray 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 val_c(val_d); + std::valarray val_f(val_d); + std::valarray 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 val_size(2); + std::valarray 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 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 val_indirect(addr, 5); + std::valarray 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; +}; diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_const_bracket.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_const_bracket.cc deleted file mode 100644 index 512cbafd3ce..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_const_bracket.cc +++ /dev/null @@ -1,48 +0,0 @@ -// 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 - -// dg-do compile - -template - void copy(P, std::size_t) { } - -template - void test(const std::valarray& v) - { - copy(&v[0], v.size()); - } - -int main() -{ - std::valarray v(190); - test(v); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_name_lookup.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_name_lookup.cc deleted file mode 100644 index 735f65f5df7..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_name_lookup.cc +++ /dev/null @@ -1,142 +0,0 @@ -// 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 - -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 Array; - Array u(10), v(10); - v = +u; - v = -u; - v = ~u; - std::valarray 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); -} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_operators.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_operators.cc deleted file mode 100644 index 70ad0b0e788..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_operators.cc +++ /dev/null @@ -1,69 +0,0 @@ -// { dg-do run } -// 2003-02-03 Volker Reichelt - -// 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 -#include - -void test01() // check unary operators -{ - bool test __attribute__((unused)) = true; - std::valarray 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 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) ); -} - -int main() -{ - test01(); - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_subset_assignment.cc b/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_subset_assignment.cc deleted file mode 100644 index 4ce22afb31a..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/numeric_arrays/valarray_subset_assignment.cc +++ /dev/null @@ -1,87 +0,0 @@ -// 2004-01-03 Jerry Quinn - -// 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 -#include - -bool check_array(std::valarray& 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 val_d(10); // 0 1 2 3 4 5 6 7 8 9 - std::valarray 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 val_c(val_d); - std::valarray val_f(val_d); - std::valarray 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 val_size(2); - std::valarray 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 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 val_indirect(addr, 5); - std::valarray 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; -}; diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/1.cc new file mode 100644 index 00000000000..2d1ebad4ced --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/1.cc @@ -0,0 +1,39 @@ +// 2006-09-24 Paolo Carlini + +// 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 +#include + +// { dg-do compile } + +struct X : public std::tr1::enable_shared_from_this +{ +}; + +int main() +{ + using __gnu_test::check_ret_type; + using std::tr1::shared_ptr; + + shared_ptr spx(new X); + check_ret_type >(spx->shared_from_this()); +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared.cc new file mode 100644 index 00000000000..c7a9dbf722c --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared.cc @@ -0,0 +1,59 @@ +// 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 +#include + +struct X : public std::tr1::enable_shared_from_this +{ +}; + +int +test01() +{ + bool test __attribute__((unused)) = true; + + X x; + + try + { + std::tr1::shared_ptr p = x.shared_from_this(); + VERIFY( false ); + } + catch (const std::tr1::bad_weak_ptr&) + { + // Expected. + VERIFY( true ); + } + catch (...) + { + // Failed. + VERIFY( false ); + } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared2.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared2.cc new file mode 100644 index 00000000000..9f5f88eea0a --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared2.cc @@ -0,0 +1,61 @@ +// 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 +#include + +struct X : public std::tr1::enable_shared_from_this +{ +}; + +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr p(new X); + + X x(*p); // copy of shared object should not be shared + + try + { + std::tr1::shared_ptr p = x.shared_from_this(); + VERIFY( false ); + } + catch (const std::tr1::bad_weak_ptr&) + { + // Expected. + VERIFY( true ); + } + catch (...) + { + // Failed. + VERIFY( false ); + } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared3.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared3.cc new file mode 100644 index 00000000000..14b203b9fd0 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/not_shared3.cc @@ -0,0 +1,63 @@ +// 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 +#include + +struct X : public std::tr1::enable_shared_from_this +{ +}; + +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr p(new X); + + X x; + x = *p; // copy of shared object should not be shared + + try + { + std::tr1::shared_ptr p = x.shared_from_this(); + VERIFY( false ); + } + catch (const std::tr1::bad_weak_ptr&) + { + // Expected. + VERIFY( true ); + } + catch (...) + { + // Failed. + VERIFY( false ); + } + + return 0; +} + + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc new file mode 100644 index 00000000000..b497ebb0a4a --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc @@ -0,0 +1,31 @@ +// 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 +#include + +// { dg-do compile } + +using namespace __gnu_test; +using std::tr1::enable_shared_from_this; +template class enable_shared_from_this; +template class enable_shared_from_this; +template class enable_shared_from_this; +template class enable_shared_from_this; diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/shared.cc new file mode 100644 index 00000000000..f860fb732a9 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/shared.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 2.2.5 Template class enable_shared_from_this [tr.util.smartptr.enab] + +#include +#include + +struct X : public std::tr1::enable_shared_from_this +{ +}; + +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr p(new X); + std::tr1::shared_ptr q = p->shared_from_this(); + VERIFY( p == q ); + VERIFY( !(p < q) && !(q < p) ); // p and q share ownership + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/still_shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/still_shared.cc new file mode 100644 index 00000000000..b9568afbe03 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/still_shared.cc @@ -0,0 +1,55 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 2.2.5 Template class enable_shared_from_this [tr.util.smartptr.enab] + +#include +#include + +struct X : public std::tr1::enable_shared_from_this +{ +}; + +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr p(new X); + + *p = X(); // assigning to shared object doesn't stop it being shared + + try + { + std::tr1::shared_ptr p2 = p->shared_from_this(); + } + catch (const std::tr1::bad_weak_ptr&) + { + test = false; + } + VERIFY( test ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/1.cc deleted file mode 100644 index 2d1ebad4ced..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/1.cc +++ /dev/null @@ -1,39 +0,0 @@ -// 2006-09-24 Paolo Carlini - -// 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 -#include - -// { dg-do compile } - -struct X : public std::tr1::enable_shared_from_this -{ -}; - -int main() -{ - using __gnu_test::check_ret_type; - using std::tr1::shared_ptr; - - shared_ptr spx(new X); - check_ret_type >(spx->shared_from_this()); -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared.cc deleted file mode 100644 index c7a9dbf722c..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared.cc +++ /dev/null @@ -1,59 +0,0 @@ -// 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 -#include - -struct X : public std::tr1::enable_shared_from_this -{ -}; - -int -test01() -{ - bool test __attribute__((unused)) = true; - - X x; - - try - { - std::tr1::shared_ptr p = x.shared_from_this(); - VERIFY( false ); - } - catch (const std::tr1::bad_weak_ptr&) - { - // Expected. - VERIFY( true ); - } - catch (...) - { - // Failed. - VERIFY( false ); - } - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared2.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared2.cc deleted file mode 100644 index 9f5f88eea0a..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared2.cc +++ /dev/null @@ -1,61 +0,0 @@ -// 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 -#include - -struct X : public std::tr1::enable_shared_from_this -{ -}; - -int -test01() -{ - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr p(new X); - - X x(*p); // copy of shared object should not be shared - - try - { - std::tr1::shared_ptr p = x.shared_from_this(); - VERIFY( false ); - } - catch (const std::tr1::bad_weak_ptr&) - { - // Expected. - VERIFY( true ); - } - catch (...) - { - // Failed. - VERIFY( false ); - } - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared3.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared3.cc deleted file mode 100644 index 14b203b9fd0..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/not_shared3.cc +++ /dev/null @@ -1,63 +0,0 @@ -// 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 -#include - -struct X : public std::tr1::enable_shared_from_this -{ -}; - -int -test01() -{ - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr p(new X); - - X x; - x = *p; // copy of shared object should not be shared - - try - { - std::tr1::shared_ptr p = x.shared_from_this(); - VERIFY( false ); - } - catch (const std::tr1::bad_weak_ptr&) - { - // Expected. - VERIFY( true ); - } - catch (...) - { - // Failed. - VERIFY( false ); - } - - return 0; -} - - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/requirements/explicit_instantiation/1.cc deleted file mode 100644 index b497ebb0a4a..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/requirements/explicit_instantiation/1.cc +++ /dev/null @@ -1,31 +0,0 @@ -// 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 -#include - -// { dg-do compile } - -using namespace __gnu_test; -using std::tr1::enable_shared_from_this; -template class enable_shared_from_this; -template class enable_shared_from_this; -template class enable_shared_from_this; -template class enable_shared_from_this; diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/shared.cc deleted file mode 100644 index f860fb732a9..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/shared.cc +++ /dev/null @@ -1,46 +0,0 @@ -// 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 -#include - -struct X : public std::tr1::enable_shared_from_this -{ -}; - -int -test01() -{ - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr p(new X); - std::tr1::shared_ptr q = p->shared_from_this(); - VERIFY( p == q ); - VERIFY( !(p < q) && !(q < p) ); // p and q share ownership - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/still_shared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/still_shared.cc deleted file mode 100644 index b9568afbe03..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/still_shared.cc +++ /dev/null @@ -1,55 +0,0 @@ -// 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 -#include - -struct X : public std::tr1::enable_shared_from_this -{ -}; - -int -test01() -{ - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr p(new X); - - *p = X(); // assigning to shared object doesn't stop it being shared - - try - { - std::tr1::shared_ptr p2 = p->shared_from_this(); - } - catch (const std::tr1::bad_weak_ptr&) - { - test = false; - } - VERIFY( test ); - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/assign.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/assign.cc deleted file mode 100644 index 93f90ce57ea..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/assign.cc +++ /dev/null @@ -1,71 +0,0 @@ -// 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 -#include - -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 -void -test01() -{ - reset_count_struct __attribute__((unused)) reset; - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr a; - - a = std::tr1::shared_ptr(new A); - VERIFY( a.get() != 0 ); - VERIFY( A::ctor_count == 1 ); - VERIFY( A::dtor_count == 0 ); - - a = std::tr1::shared_ptr(); - VERIFY( a.get() == 0 ); - VERIFY( A::ctor_count == 1 ); - VERIFY( A::dtor_count == 1 ); -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr.cc deleted file mode 100644 index 9a36f95cb07..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr.cc +++ /dev/null @@ -1,84 +0,0 @@ -// 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 -#include - -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 -int -test01() -{ - reset_count_struct __attribute__((unused)) reset; - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr a(new A); - std::auto_ptr b(new B); - a = b; - VERIFY( a.get() != 0 ); - VERIFY( b.get() == 0 ); - VERIFY( A::ctor_count == 2 ); - VERIFY( A::dtor_count == 1 ); - VERIFY( B::ctor_count == 1 ); - VERIFY( B::dtor_count == 0 ); - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_neg.cc deleted file mode 100644 index cca1049c12b..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_neg.cc +++ /dev/null @@ -1,50 +0,0 @@ -// { 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 -#include - -struct A { }; -struct B { }; - -// 2.2.3.3 shared_ptr assignment [tr.util.smartptr.shared.assign] - -// Assignment from incompatible auto_ptr -int -test01() -{ - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr a; - std::auto_ptr b; - a = b; // { dg-error "here" } - - return 0; -} - -int -main() -{ - test01(); - return 0; -} -// { dg-excess-errors "In constructor" } diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_rvalue_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_rvalue_neg.cc deleted file mode 100644 index da023294f99..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/auto_ptr_rvalue_neg.cc +++ /dev/null @@ -1,49 +0,0 @@ -// { 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 -#include - -struct A { }; -std::auto_ptr source() { return std::auto_ptr(); } - -// 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 = source(); // { dg-error "no match" } - - return 0; -} - -int -main() -{ - test01(); - return 0; -} -// { dg-excess-errors "candidates are" } diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/dr541.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/dr541.cc deleted file mode 100644 index f9dc8393504..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/dr541.cc +++ /dev/null @@ -1,30 +0,0 @@ -// { 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 - -// DR 541. shared_ptr template assignment and void -void test01() -{ - std::tr1::shared_ptr p; - p.operator=(p); -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr.cc deleted file mode 100644 index 90ab7eec03f..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr.cc +++ /dev/null @@ -1,95 +0,0 @@ -// 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 -#include - -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 -void -test01() -{ - reset_count_struct __attribute__((unused)) reset; - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr a; - - a = std::tr1::shared_ptr(); - 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(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(new B); - VERIFY( a.get() != 0 ); - VERIFY( A::ctor_count == 2 ); - VERIFY( A::dtor_count == 1 ); - VERIFY( B::ctor_count == 1 ); - VERIFY( B::dtor_count == 0 ); -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr_neg.cc deleted file mode 100644 index 407cc5b0bf5..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/assign/shared_ptr_neg.cc +++ /dev/null @@ -1,52 +0,0 @@ -// { 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 -#include - -struct A { }; -struct B { }; - -// 2.2.3.3 shared_ptr assignment [tr.util.smartptr.shared.assign] - -// Assignment from incompatible shared_ptr -int -test01() -{ - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr a; - std::tr1::shared_ptr b; - a = b; // { dg-error "here" } - - return 0; -} - -int -main() -{ - test01(); - return 0; -} -// { dg-error "In member function" "" { target *-*-* } 0 } -// { dg-error "cannot convert" "" { target *-*-* } 0 } -// { dg-error "instantiated from" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc deleted file mode 100644 index 8851f254b4d..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc +++ /dev/null @@ -1,46 +0,0 @@ -// 2006-09-24 Paolo Carlini - -// 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 -#include - -// { 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 spd; - shared_ptr spci; - shared_ptr spa; - - check_ret_type >(static_pointer_cast(spd)); - check_ret_type >(const_pointer_cast(spci)); - check_ret_type >(static_pointer_cast(spa)); -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/comparison/cmp.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/comparison/cmp.cc deleted file mode 100644 index 15b7b1e6ac0..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/comparison/cmp.cc +++ /dev/null @@ -1,83 +0,0 @@ -// 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 -#include - -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 p1; - std::tr1::shared_ptr p2; - VERIFY( p1 == p2 ); - VERIFY( !(p1 != p2) ); - VERIFY( !(p1 < p2) && !(p2 < p1) ); - return 0; -} - - -// Construction from pointer -int -test02() -{ - std::tr1::shared_ptr A_default; - - std::tr1::shared_ptr 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_from_B(new B); - VERIFY( B_from_B != A_from_A ); - VERIFY( !(B_from_B == A_from_A) ); - VERIFY( (B_from_B < A_from_A) || (A_from_A < B_from_B) ); - - A_from_A.reset(); - VERIFY( A_default == A_from_A ); - VERIFY( !(A_default != A_from_A) ); - VERIFY( !(A_default < A_from_A) && !(A_from_A < A_default) ); - - B_from_B.reset(); - VERIFY( B_from_B == A_from_A ); - VERIFY( !(B_from_B != A_from_A) ); - VERIFY( !(B_from_B < A_from_A) && !(A_from_A < B_from_B) ); - - return 0; -} - -int -main() -{ - test01(); - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr.cc deleted file mode 100644 index b91c5a26cfe..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr.cc +++ /dev/null @@ -1,48 +0,0 @@ -// 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 -#include - -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(new A); - std::tr1::shared_ptr a2(a); - VERIFY( a.get() == 0 ); - VERIFY( a2.get() != 0 ); - VERIFY( a2.use_count() == 1 ); - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr_neg.cc deleted file mode 100644 index c2a3202ccad..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/auto_ptr_neg.cc +++ /dev/null @@ -1,48 +0,0 @@ -// { 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 -#include - -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; - std::tr1::shared_ptr p(a); // { dg-error "no match" } - - return 0; -} - -int -main() -{ - test01(); - return 0; -} -// { dg-excess-errors "candidates are" } diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/copy.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/copy.cc deleted file mode 100644 index cc529e0639b..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/copy.cc +++ /dev/null @@ -1,135 +0,0 @@ -// 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 -#include - -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 a1; - std::tr1::shared_ptr 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 a1(new A); - std::tr1::shared_ptr 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(new B); - std::tr1::shared_ptr 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(new B, &deleter); - std::tr1::shared_ptr a(b); - VERIFY( a.use_count() == 2 ); - VERIFY( A::ctor_count == 1 ); - VERIFY( A::dtor_count == 0 ); - VERIFY( B::ctor_count == 1 ); - VERIFY( B::dtor_count == 0 ); - - return 0; -} - -int -main() -{ - test01(); - test02(); - test03(); - test04(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/default.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/default.cc deleted file mode 100644 index 641834da6cc..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/default.cc +++ /dev/null @@ -1,45 +0,0 @@ -// 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 -#include - -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; - VERIFY( a.get() == 0 ); - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/pointer.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/pointer.cc deleted file mode 100644 index dec051451a2..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/pointer.cc +++ /dev/null @@ -1,79 +0,0 @@ -// 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 -#include - -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 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 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 p(b); - VERIFY( p.get() == b ); - VERIFY( p.use_count() == 1 ); - - return 0; -} - -int -main() -{ - test01(); - test02(); - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr.cc deleted file mode 100644 index 048d93ac960..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr.cc +++ /dev/null @@ -1,50 +0,0 @@ -// 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 -#include - -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 a1(a); - std::tr1::weak_ptr wa(a1); - std::tr1::shared_ptr a2(wa); - VERIFY( a2.get() == a ); - VERIFY( a2.use_count() == wa.use_count() ); - - return 0; -} - - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr_expired.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr_expired.cc deleted file mode 100644 index d40227ade1c..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/cons/weak_ptr_expired.cc +++ /dev/null @@ -1,61 +0,0 @@ -// { 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 -#include - -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 a1(new A); - std::tr1::weak_ptr wa(a1); - a1.reset(); - VERIFY( wa.expired() ); - try - { - std::tr1::shared_ptr a2(wa); - } - catch (const std::tr1::bad_weak_ptr&) - { - // Expected. - __throw_exception_again; - } - catch (...) - { - // Failed. - } - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/dest/dest.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/dest/dest.cc deleted file mode 100644 index a632264c75c..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/dest/dest.cc +++ /dev/null @@ -1,133 +0,0 @@ -// 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 -#include - -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; - } - 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 = std::tr1::shared_ptr(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 a1(new B); - std::tr1::shared_ptr a2(new B, D()); - } - VERIFY( A::ctor_count == 2 ); - VERIFY( A::dtor_count == 2 ); - VERIFY( B::ctor_count == 2 ); - VERIFY( B::dtor_count == 2 ); - VERIFY( D::delete_count == 1 ); - - return 0; -} - - -int -main() -{ - test01(); - test02(); - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/24595.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/24595.cc deleted file mode 100644 index 71cbd0b41a1..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/24595.cc +++ /dev/null @@ -1,39 +0,0 @@ -// 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 -#include - -using std::tr1::get_deleter; - -// libstdc++/24595 -void test01() -{ - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr sp; - VERIFY( !get_deleter(sp) ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/io.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/io.cc deleted file mode 100644 index 51de755ebd3..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/io.cc +++ /dev/null @@ -1,51 +0,0 @@ -// 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 -#include -#include - -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 p(new A); - std::ostringstream buf; - buf << p; - const std::string s = buf.str(); - buf.str(""); - buf << p.get(); - VERIFY( s == buf.str() ); - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/swap.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/swap.cc deleted file mode 100644 index c22b2f8ab37..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/misc/swap.cc +++ /dev/null @@ -1,50 +0,0 @@ -// 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 -#include - -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 p1(a1); - std::tr1::shared_ptr p2(a2); - std::swap(p1, p2); - VERIFY( p1.get() == a2 ); - VERIFY( p2.get() == a1 ); - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/24805.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/24805.cc deleted file mode 100644 index 94824f6167d..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/24805.cc +++ /dev/null @@ -1,30 +0,0 @@ -// { 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 - -// 2.2.3.4 shared_ptr modifiers [tr.util.smartptr.shared.mod] - -// swap - -// libstdc++/24805 -using std::tr1::swap; diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset.cc deleted file mode 100644 index 244a9f29a3f..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset.cc +++ /dev/null @@ -1,88 +0,0 @@ -// 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 -#include - -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 p1(a); - std::tr1::shared_ptr 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 p1(a); - std::tr1::shared_ptr 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 p1; - p1.reset(new B, D()); - } - VERIFY( D::delete_count == 1 ); - - return 0; -} - -int -main() -{ - test01(); - test02(); - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset_neg.cc deleted file mode 100644 index 136d2b76ddb..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/reset_neg.cc +++ /dev/null @@ -1,47 +0,0 @@ -// { 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 -#include - -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 p1(new A); - p1.reset(); // { dg-error "discards qualifiers" } - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap.cc deleted file mode 100644 index eb251b59102..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap.cc +++ /dev/null @@ -1,50 +0,0 @@ -// 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 -#include - -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 p1(a1); - std::tr1::shared_ptr p2(a2); - p1.swap(p2); - VERIFY( p1.get() == a2 ); - VERIFY( p2.get() == a1 ); - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap_neg.cc deleted file mode 100644 index 606d8e3921a..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/swap_neg.cc +++ /dev/null @@ -1,48 +0,0 @@ -// { 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 -#include - -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 p1(new A); - std::tr1::shared_ptr p2(new A); - p1.swap(p2); // { dg-error "discards qualifiers" } - - return 0; -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/bool_conv.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/bool_conv.cc deleted file mode 100644 index 94558848e87..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/bool_conv.cc +++ /dev/null @@ -1,80 +0,0 @@ -// 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 -#include - -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 p1; - VERIFY( p1 == false ); - const std::tr1::shared_ptr p2(p1); - VERIFY( p2 == false ); - - return 0; -} - -int -test02() -{ - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr p1(new A); - VERIFY( p1 ); - std::tr1::shared_ptr p2(p1); - VERIFY( p2 ); - p1.reset(); - VERIFY( !p1 ); - VERIFY( p2 ); - - return 0; -} - -int -test03() -{ - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr p1(new A); - std::tr1::shared_ptr p2(p1); - p2.reset(new A); - VERIFY( p1 ); - VERIFY( p2 ); - - return 0; -} - - -int -main() -{ - test01(); - test02(); - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/get.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/get.cc deleted file mode 100644 index d85ec665772..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/get.cc +++ /dev/null @@ -1,80 +0,0 @@ -// 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 -#include - -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 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 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 p(a); - VERIFY( &p->i == &a->i ); - - return 0; -} - - -int -main() -{ - test01(); - test02(); - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/unique.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/unique.cc deleted file mode 100644 index 81253e44b0f..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/unique.cc +++ /dev/null @@ -1,80 +0,0 @@ -// 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 -#include - -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 p1; - VERIFY( !p1.unique() ); - const std::tr1::shared_ptr p2(p1); - VERIFY( !p1.unique() ); - - return 0; -} - -int -test02() -{ - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr p1(new A); - VERIFY( p1.unique() ); - std::tr1::shared_ptr 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 p1(new A); - std::tr1::shared_ptr p2(p1); - p2.reset(new A); - VERIFY( p1.unique() ); - VERIFY( p2.unique() ); - - return 0; -} - - -int -main() -{ - test01(); - test02(); - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/use_count.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/use_count.cc deleted file mode 100644 index 85f18504619..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/observers/use_count.cc +++ /dev/null @@ -1,79 +0,0 @@ -// 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 -#include - -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 p1; - VERIFY( p1.use_count() == 0 ); - const std::tr1::shared_ptr p2(p1); - VERIFY( p1.use_count() == 0 ); - - return 0; -} - -int -test02() -{ - bool test __attribute__((unused)) = true; - - std::tr1::shared_ptr p1(new A); - std::tr1::shared_ptr 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 p1(new A); - std::tr1::shared_ptr p2(p1); - p2.reset(new B); - VERIFY( p1.use_count() == 1 ); - VERIFY( p2.use_count() == 1 ); - - return 0; -} - - -int -main() -{ - test01(); - test02(); - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/requirements/explicit_instantiation/1.cc deleted file mode 100644 index 015e22ec79b..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/requirements/explicit_instantiation/1.cc +++ /dev/null @@ -1,31 +0,0 @@ -// 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 -#include - -// { dg-do compile } - -using namespace __gnu_test; -using std::tr1::shared_ptr; -template class shared_ptr; -template class shared_ptr; -template class shared_ptr; -template class shared_ptr; diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/thread/default_weaktoshared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/thread/default_weaktoshared.cc deleted file mode 100644 index 5b17500165f..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/thread/default_weaktoshared.cc +++ /dev/null @@ -1,193 +0,0 @@ -// 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 -#include -#include -#include -#include - -#include - -#ifdef _GLIBCXX_HAVE_UNISTD_H -#include // 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::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 sp_A_t; -typedef std::tr1::weak_ptr wp_A_t; - -typedef std::vector sp_vector_t; -typedef std::vector 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(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(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 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(&pools)); - for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++) - { - if (pthread_create(&threads[worker], &tattr, - thread_hammer, reinterpret_cast(&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; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/thread/mutex_weaktoshared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/thread/mutex_weaktoshared.cc deleted file mode 100644 index 370218a1136..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/thread/mutex_weaktoshared.cc +++ /dev/null @@ -1,195 +0,0 @@ -// 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 -#include -#include -#include -#include - -#include - -#ifdef _GLIBCXX_HAVE_UNISTD_H -#include // 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::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 sp_A_t; -typedef std::tr1::__weak_ptr wp_A_t; - -typedef std::vector sp_vector_t; -typedef std::vector 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(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(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 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(&pools)); - for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++) - { - if (pthread_create(&threads[worker], &tattr, - thread_hammer, reinterpret_cast(&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; -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc deleted file mode 100644 index 0367b310059..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc +++ /dev/null @@ -1,36 +0,0 @@ -// 2006-09-24 Paolo Carlini - -// 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 -#include - -// { dg-do compile } - -int main() -{ - using __gnu_test::check_ret_type; - using std::tr1::weak_ptr; - using std::tr1::shared_ptr; - - weak_ptr wp; - check_ret_type >(wp.lock()); -} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/weak_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/weak_ptr/requirements/explicit_instantiation/1.cc deleted file mode 100644 index 6c22459dab6..00000000000 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/weak_ptr/requirements/explicit_instantiation/1.cc +++ /dev/null @@ -1,31 +0,0 @@ -// 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 -#include - -// { dg-do compile } - -using namespace __gnu_test; -using std::tr1::weak_ptr; -template class weak_ptr; -template class weak_ptr; -template class weak_ptr; -template class weak_ptr; diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/assign.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/assign.cc new file mode 100644 index 00000000000..93f90ce57ea --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/assign.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr a; + + a = std::tr1::shared_ptr(new A); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + a = std::tr1::shared_ptr(); + VERIFY( a.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr.cc new file mode 100644 index 00000000000..9a36f95cb07 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 +int +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr a(new A); + std::auto_ptr b(new B); + a = b; + VERIFY( a.get() != 0 ); + VERIFY( b.get() == 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_neg.cc new file mode 100644 index 00000000000..cca1049c12b --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_neg.cc @@ -0,0 +1,50 @@ +// { 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 +#include + +struct A { }; +struct B { }; + +// 2.2.3.3 shared_ptr assignment [tr.util.smartptr.shared.assign] + +// Assignment from incompatible auto_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr a; + std::auto_ptr b; + a = b; // { dg-error "here" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "In constructor" } diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_rvalue_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_rvalue_neg.cc new file mode 100644 index 00000000000..da023294f99 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_rvalue_neg.cc @@ -0,0 +1,49 @@ +// { 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 +#include + +struct A { }; +std::auto_ptr source() { return std::auto_ptr(); } + +// 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 = source(); // { dg-error "no match" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "candidates are" } diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/dr541.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/dr541.cc new file mode 100644 index 00000000000..f9dc8393504 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/dr541.cc @@ -0,0 +1,30 @@ +// { 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 + +// DR 541. shared_ptr template assignment and void +void test01() +{ + std::tr1::shared_ptr p; + p.operator=(p); +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr.cc new file mode 100644 index 00000000000..90ab7eec03f --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr.cc @@ -0,0 +1,95 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr a; + + a = std::tr1::shared_ptr(); + 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(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(new B); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr_neg.cc new file mode 100644 index 00000000000..407cc5b0bf5 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/assign/shared_ptr_neg.cc @@ -0,0 +1,52 @@ +// { 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 +#include + +struct A { }; +struct B { }; + +// 2.2.3.3 shared_ptr assignment [tr.util.smartptr.shared.assign] + +// Assignment from incompatible shared_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr a; + std::tr1::shared_ptr b; + a = b; // { dg-error "here" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-error "In member function" "" { target *-*-* } 0 } +// { dg-error "cannot convert" "" { target *-*-* } 0 } +// { dg-error "instantiated from" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/casts/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/casts/1.cc new file mode 100644 index 00000000000..8851f254b4d --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/casts/1.cc @@ -0,0 +1,46 @@ +// 2006-09-24 Paolo Carlini + +// 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 +#include + +// { 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 spd; + shared_ptr spci; + shared_ptr spa; + + check_ret_type >(static_pointer_cast(spd)); + check_ret_type >(const_pointer_cast(spci)); + check_ret_type >(static_pointer_cast(spa)); +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/comparison/cmp.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/comparison/cmp.cc new file mode 100644 index 00000000000..15b7b1e6ac0 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/comparison/cmp.cc @@ -0,0 +1,83 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 p1; + std::tr1::shared_ptr p2; + VERIFY( p1 == p2 ); + VERIFY( !(p1 != p2) ); + VERIFY( !(p1 < p2) && !(p2 < p1) ); + return 0; +} + + +// Construction from pointer +int +test02() +{ + std::tr1::shared_ptr A_default; + + std::tr1::shared_ptr 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_from_B(new B); + VERIFY( B_from_B != A_from_A ); + VERIFY( !(B_from_B == A_from_A) ); + VERIFY( (B_from_B < A_from_A) || (A_from_A < B_from_B) ); + + A_from_A.reset(); + VERIFY( A_default == A_from_A ); + VERIFY( !(A_default != A_from_A) ); + VERIFY( !(A_default < A_from_A) && !(A_from_A < A_default) ); + + B_from_B.reset(); + VERIFY( B_from_B == A_from_A ); + VERIFY( !(B_from_B != A_from_A) ); + VERIFY( !(B_from_B < A_from_A) && !(A_from_A < B_from_B) ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr.cc new file mode 100644 index 00000000000..b91c5a26cfe --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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(new A); + std::tr1::shared_ptr a2(a); + VERIFY( a.get() == 0 ); + VERIFY( a2.get() != 0 ); + VERIFY( a2.use_count() == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr_neg.cc new file mode 100644 index 00000000000..c2a3202ccad --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr_neg.cc @@ -0,0 +1,48 @@ +// { 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 +#include + +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; + std::tr1::shared_ptr p(a); // { dg-error "no match" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "candidates are" } diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/copy.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/copy.cc new file mode 100644 index 00000000000..cc529e0639b --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/copy.cc @@ -0,0 +1,135 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 a1; + std::tr1::shared_ptr 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 a1(new A); + std::tr1::shared_ptr 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(new B); + std::tr1::shared_ptr 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(new B, &deleter); + std::tr1::shared_ptr a(b); + VERIFY( a.use_count() == 2 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/default.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/default.cc new file mode 100644 index 00000000000..641834da6cc --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/default.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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; + VERIFY( a.get() == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/pointer.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/pointer.cc new file mode 100644 index 00000000000..dec051451a2 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/pointer.cc @@ -0,0 +1,79 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 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 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 p(b); + VERIFY( p.get() == b ); + VERIFY( p.use_count() == 1 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr.cc new file mode 100644 index 00000000000..048d93ac960 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 a1(a); + std::tr1::weak_ptr wa(a1); + std::tr1::shared_ptr a2(wa); + VERIFY( a2.get() == a ); + VERIFY( a2.use_count() == wa.use_count() ); + + return 0; +} + + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr_expired.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr_expired.cc new file mode 100644 index 00000000000..d40227ade1c --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/weak_ptr_expired.cc @@ -0,0 +1,61 @@ +// { 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 +#include + +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 a1(new A); + std::tr1::weak_ptr wa(a1); + a1.reset(); + VERIFY( wa.expired() ); + try + { + std::tr1::shared_ptr a2(wa); + } + catch (const std::tr1::bad_weak_ptr&) + { + // Expected. + __throw_exception_again; + } + catch (...) + { + // Failed. + } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/dest/dest.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/dest/dest.cc new file mode 100644 index 00000000000..a632264c75c --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/dest/dest.cc @@ -0,0 +1,133 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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; + } + 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 = std::tr1::shared_ptr(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 a1(new B); + std::tr1::shared_ptr a2(new B, D()); + } + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( B::ctor_count == 2 ); + VERIFY( B::dtor_count == 2 ); + VERIFY( D::delete_count == 1 ); + + return 0; +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/24595.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/24595.cc new file mode 100644 index 00000000000..71cbd0b41a1 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/24595.cc @@ -0,0 +1,39 @@ +// 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 +#include + +using std::tr1::get_deleter; + +// libstdc++/24595 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr sp; + VERIFY( !get_deleter(sp) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/io.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/io.cc new file mode 100644 index 00000000000..51de755ebd3 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/io.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include +#include + +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 p(new A); + std::ostringstream buf; + buf << p; + const std::string s = buf.str(); + buf.str(""); + buf << p.get(); + VERIFY( s == buf.str() ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/swap.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/swap.cc new file mode 100644 index 00000000000..c22b2f8ab37 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/swap.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 p1(a1); + std::tr1::shared_ptr p2(a2); + std::swap(p1, p2); + VERIFY( p1.get() == a2 ); + VERIFY( p2.get() == a1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/24805.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/24805.cc new file mode 100644 index 00000000000..94824f6167d --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/24805.cc @@ -0,0 +1,30 @@ +// { 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 + +// 2.2.3.4 shared_ptr modifiers [tr.util.smartptr.shared.mod] + +// swap + +// libstdc++/24805 +using std::tr1::swap; diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset.cc new file mode 100644 index 00000000000..244a9f29a3f --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset.cc @@ -0,0 +1,88 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 p1(a); + std::tr1::shared_ptr 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 p1(a); + std::tr1::shared_ptr 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 p1; + p1.reset(new B, D()); + } + VERIFY( D::delete_count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset_neg.cc new file mode 100644 index 00000000000..136d2b76ddb --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/reset_neg.cc @@ -0,0 +1,47 @@ +// { 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 +#include + +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 p1(new A); + p1.reset(); // { dg-error "discards qualifiers" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap.cc new file mode 100644 index 00000000000..eb251b59102 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 p1(a1); + std::tr1::shared_ptr p2(a2); + p1.swap(p2); + VERIFY( p1.get() == a2 ); + VERIFY( p2.get() == a1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap_neg.cc new file mode 100644 index 00000000000..606d8e3921a --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/modifiers/swap_neg.cc @@ -0,0 +1,48 @@ +// { 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 +#include + +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 p1(new A); + std::tr1::shared_ptr p2(new A); + p1.swap(p2); // { dg-error "discards qualifiers" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/bool_conv.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/bool_conv.cc new file mode 100644 index 00000000000..94558848e87 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/bool_conv.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 p1; + VERIFY( p1 == false ); + const std::tr1::shared_ptr p2(p1); + VERIFY( p2 == false ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr p1(new A); + VERIFY( p1 ); + std::tr1::shared_ptr p2(p1); + VERIFY( p2 ); + p1.reset(); + VERIFY( !p1 ); + VERIFY( p2 ); + + return 0; +} + +int +test03() +{ + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr p1(new A); + std::tr1::shared_ptr p2(p1); + p2.reset(new A); + VERIFY( p1 ); + VERIFY( p2 ); + + return 0; +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/get.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/get.cc new file mode 100644 index 00000000000..d85ec665772 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/get.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 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 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 p(a); + VERIFY( &p->i == &a->i ); + + return 0; +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/unique.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/unique.cc new file mode 100644 index 00000000000..81253e44b0f --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/unique.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 p1; + VERIFY( !p1.unique() ); + const std::tr1::shared_ptr p2(p1); + VERIFY( !p1.unique() ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr p1(new A); + VERIFY( p1.unique() ); + std::tr1::shared_ptr 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 p1(new A); + std::tr1::shared_ptr p2(p1); + p2.reset(new A); + VERIFY( p1.unique() ); + VERIFY( p2.unique() ); + + return 0; +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/use_count.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/use_count.cc new file mode 100644 index 00000000000..85f18504619 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/use_count.cc @@ -0,0 +1,79 @@ +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared] + +#include +#include + +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 p1; + VERIFY( p1.use_count() == 0 ); + const std::tr1::shared_ptr p2(p1); + VERIFY( p1.use_count() == 0 ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::tr1::shared_ptr p1(new A); + std::tr1::shared_ptr 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 p1(new A); + std::tr1::shared_ptr p2(p1); + p2.reset(new B); + VERIFY( p1.use_count() == 1 ); + VERIFY( p2.use_count() == 1 ); + + return 0; +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 00000000000..015e22ec79b --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,31 @@ +// 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 +#include + +// { dg-do compile } + +using namespace __gnu_test; +using std::tr1::shared_ptr; +template class shared_ptr; +template class shared_ptr; +template class shared_ptr; +template class shared_ptr; diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc new file mode 100644 index 00000000000..5b17500165f --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc @@ -0,0 +1,193 @@ +// 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 +#include +#include +#include +#include + +#include + +#ifdef _GLIBCXX_HAVE_UNISTD_H +#include // 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::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 sp_A_t; +typedef std::tr1::weak_ptr wp_A_t; + +typedef std::vector sp_vector_t; +typedef std::vector 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(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(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 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(&pools)); + for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_create(&threads[worker], &tattr, + thread_hammer, reinterpret_cast(&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; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc new file mode 100644 index 00000000000..370218a1136 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc @@ -0,0 +1,195 @@ +// 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 +#include +#include +#include +#include + +#include + +#ifdef _GLIBCXX_HAVE_UNISTD_H +#include // 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::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 sp_A_t; +typedef std::tr1::__weak_ptr wp_A_t; + +typedef std::vector sp_vector_t; +typedef std::vector 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(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(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 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(&pools)); + for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_create(&threads[worker], &tattr, + thread_hammer, reinterpret_cast(&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; +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/lock/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/lock/1.cc new file mode 100644 index 00000000000..0367b310059 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/lock/1.cc @@ -0,0 +1,36 @@ +// 2006-09-24 Paolo Carlini + +// 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 +#include + +// { dg-do compile } + +int main() +{ + using __gnu_test::check_ret_type; + using std::tr1::weak_ptr; + using std::tr1::shared_ptr; + + weak_ptr wp; + check_ret_type >(wp.lock()); +} diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 00000000000..6c22459dab6 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,31 @@ +// 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 +#include + +// { dg-do compile } + +using namespace __gnu_test; +using std::tr1::weak_ptr; +template class weak_ptr; +template class weak_ptr; +template class weak_ptr; +template class weak_ptr;