diff options
author | aldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-08 03:20:30 +0000 |
---|---|---|
committer | aldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-08 03:20:30 +0000 |
commit | 643df0593c630691fa6877cddeefdd4c3023d444 (patch) | |
tree | 1eb48ad31d05a9ce117bedc17115de96dffa2f0b /libstdc++-v3/testsuite | |
parent | 54f3f029d816c6d1626310649adfda740e203f7b (diff) | |
parent | d5d8f1ccc6d3972dc5cfc0949e85e0b1c9e24ee0 (diff) | |
download | gcc-643df0593c630691fa6877cddeefdd4c3023d444.tar.gz |
* Merge from mainline rev 181122.transactional-memory
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/transactional-memory@181148 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
23 files changed, 654 insertions, 104 deletions
diff --git a/libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc b/libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc new file mode 100644 index 00000000000..a72d65faf73 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <cstdalign> + +// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 } + diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/char/pop_back.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/char/pop_back.cc new file mode 100644 index 00000000000..1f0f3d884fb --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/char/pop_back.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 21.4.6.5 basic_string::pop_back +// { dg-options "-std=gnu++0x" } + +#include <string> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + const std::string cstr("Badger"); + std::string str = cstr; + str.pop_back(); + VERIFY( str.size() == cstr.size() - 1 ); + + str += cstr.back(); + VERIFY( str == cstr ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/wchar_t/pop_back.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/wchar_t/pop_back.cc new file mode 100644 index 00000000000..fb5db8c1380 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/wchar_t/pop_back.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 21.4.6.5 basic_string::pop_back +// { dg-options "-std=gnu++0x" } + +#include <string> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + const std::wstring cstr(L"Badger"); + std::wstring str = cstr; + str.pop_back(); + VERIFY( str.size() == cstr.size() - 1 ); + + str += cstr.back(); + VERIFY( str == cstr ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/range_access/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/range_access/char/1.cc new file mode 100644 index 00000000000..458bf53e2c5 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/range_access/char/1.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <string> + +void +test01() +{ + std::string s("Hello, World!"); + std::begin(s); + std::end(s); +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/range_access.cc b/libstdc++-v3/testsuite/21_strings/basic_string/range_access/wchar_t/1.cc index 1ce386cbe96..e300b092389 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/range_access.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/range_access/wchar_t/1.cc @@ -1,7 +1,7 @@ // { dg-do compile } // { dg-options "-std=gnu++0x" } -// Copyright (C) 2010 Free Software Foundation, Inc. +// Copyright (C) 2010. 2011 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 @@ -25,10 +25,6 @@ void test01() { - std::string s("Hello, World!"); - std::begin(s); - std::end(s); - #ifdef _GLIBCXX_USE_WCHAR_T std::wstring ws(L"Hello, World!"); std::begin(ws); diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc index 7aec649c03b..4249d975a82 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc @@ -3,7 +3,7 @@ // // 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> // -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010, 2011 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 @@ -46,6 +46,20 @@ test01() str >> v; VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); + + str.clear(); + str << v; + + u(); + u(); + u(); + + str >> u; + VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); } int main() diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/serialize.cc index 332931addfa..32a5157608c 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/serialize.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/serialize.cc @@ -3,7 +3,7 @@ // // 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> // -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010, 2011 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 @@ -44,6 +44,20 @@ test01() str >> v; VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); + + str.clear(); + str << v; + + u(); + u(); + u(); + + str >> u; + VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); } int main() diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/serialize.cc index 8b67e5f3a33..a83b22ef651 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/serialize.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/serialize.cc @@ -3,7 +3,7 @@ // // 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> // -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010, 2011 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 @@ -33,15 +33,29 @@ test01() bool test __attribute__((unused)) = true; std::stringstream str; - std::minstd_rand0 a; - std::minstd_rand0 b; + std::minstd_rand0 u; + std::minstd_rand0 v; - a(); // advance - str << a; - VERIFY( !(a == b) ); + u(); // advance + str << u; + VERIFY( !(u == v) ); - str >> b; - VERIFY( a == b ); + str >> v; + VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); + + str.clear(); + str << v; + + u(); + u(); + u(); + + str >> u; + VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); } int main() diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/serialize.cc index 03fb8b04fa1..7c90e3d390f 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/serialize.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/serialize.cc @@ -3,7 +3,7 @@ // // 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> // -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010, 2011 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 @@ -47,6 +47,20 @@ test01() str >> v; VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); + + str.clear(); + str << v; + + u(); + u(); + u(); + + str >> u; + VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); } int main() diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/serialize.cc index 578e4959371..c7b15d1ba15 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/serialize.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/serialize.cc @@ -3,7 +3,7 @@ // // 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> // -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010, 2011 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 @@ -46,6 +46,20 @@ test01() str >> v; VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); + + str.clear(); + str << v; + + u(); + u(); + u(); + + str >> u; + VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); } int main() diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/serialize.cc index e4129fc8df5..1e2e53ac593 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/serialize.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/serialize.cc @@ -3,7 +3,7 @@ // // 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> // -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010, 2011 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 @@ -43,6 +43,20 @@ test01() str >> v; VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); + + str.clear(); + str << v; + + u(); + u(); + u(); + + str >> u; + VERIFY( u == v ); + for (unsigned i = 0; i < 1000; ++i) + VERIFY( u() == v() ); } int main() diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/user_pod.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/user_pod.cc index 4ace9f0cd63..6053efca902 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/user_pod.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/user_pod.cc @@ -1,7 +1,7 @@ // { dg-options "-std=gnu++0x" } -// { dg-do link { xfail *-*-* } } +// { dg-do link } -// Copyright (C) 2009 Free Software Foundation, Inc. +// Copyright (C) 2009, 2011 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 @@ -29,7 +29,7 @@ struct dwordp void atomics() { std::atomic<dwordp> a; - bool b = a.is_lock_free(); // { dg-excess-errors "undefined reference to" } + bool b = a.is_lock_free(); } int main() diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/29_atomics/atomic/requirements/explicit_instantiation/1.cc index 72bd5dd3a97..690f1215352 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/requirements/explicit_instantiation/1.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/requirements/explicit_instantiation/1.cc @@ -23,5 +23,5 @@ #include <atomic> #include <testsuite_character.h> -template class std::atomic<__gnu_test::pod_char>; +template class std::atomic<__gnu_test::pod_state>; template class std::atomic<__gnu_test::pod_char*>; diff --git a/libstdc++-v3/testsuite/29_atomics/headers/atomic/macros.cc b/libstdc++-v3/testsuite/29_atomics/headers/atomic/macros.cc index e2461a1113e..450fb6c2cc7 100644 --- a/libstdc++-v3/testsuite/29_atomics/headers/atomic/macros.cc +++ b/libstdc++-v3/testsuite/29_atomics/headers/atomic/macros.cc @@ -20,78 +20,36 @@ #include <atomic> -namespace gnu -{ #ifndef ATOMIC_CHAR_LOCK_FREE # error "ATOMIC_CHAR_LOCK_FREE must be a macro" -#else -# if ATOMIC_CHAR_LOCK_FREE != 0 \ - && ATOMIC_CHAR_LOCK_FREE != 1 && ATOMIC_CHAR_LOCK_FREE != 2 -# error "ATOMIC_CHAR_LOCK_FREE must be 0, 1, or 2" -# endif #endif #ifndef ATOMIC_CHAR16_T_LOCK_FREE # error "ATOMIC_CHAR16_T_LOCK_FREE must be a macro" -#else -# if ATOMIC_CHAR16_T_LOCK_FREE != 0 \ - && ATOMIC_CHAR16_T_LOCK_FREE != 1 && ATOMIC_CHAR16_T_LOCK_FREE != 2 -# error "ATOMIC_CHAR16_T_LOCK_FREE must be 0, 1, or 2" -# endif #endif #ifndef ATOMIC_CHAR32_T_LOCK_FREE # error "ATOMIC_CHAR32_T_LOCK_FREE must be a macro" -#else -# if ATOMIC_CHAR32_T_LOCK_FREE != 0 \ - && ATOMIC_CHAR32_T_LOCK_FREE != 1 && ATOMIC_CHAR32_T_LOCK_FREE != 2 -# error "ATOMIC_CHAR32_T_LOCK_FREE must be 0, 1, or 2" -# endif #endif #ifndef ATOMIC_WCHAR_T_LOCK_FREE # error "ATOMIC_WCHAR_T_LOCK_FREE must be a macro" -#else -# if ATOMIC_WCHAR_T_LOCK_FREE != 0 \ - && ATOMIC_WCHAR_T_LOCK_FREE != 1 && ATOMIC_WCHAR_T_LOCK_FREE != 2 -# error "ATOMIC_WCHAR_T_LOCK_FREE must be 0, 1, or 2" -# endif #endif #ifndef ATOMIC_SHORT_LOCK_FREE # error "ATOMIC_SHORT_LOCK_FREE must be a macro" -#else -# if ATOMIC_SHORT_LOCK_FREE != 0 \ - && ATOMIC_SHORT_LOCK_FREE != 1 && ATOMIC_SHORT_LOCK_FREE != 2 -# error "ATOMIC_SHORT_LOCK_FREE must be 0, 1, or 2" -# endif #endif #ifndef ATOMIC_INT_LOCK_FREE # error "ATOMIC_INT_LOCK_FREE must be a macro" -#else -# if ATOMIC_INT_LOCK_FREE != 0 \ - && ATOMIC_INT_LOCK_FREE != 1 && ATOMIC_INT_LOCK_FREE != 2 -# error "ATOMIC_INT_LOCK_FREE must be 0, 1, or 2" -# endif #endif #ifndef ATOMIC_LONG_LOCK_FREE # error "ATOMIC_LONG_LOCK_FREE must be a macro" -#else -# if ATOMIC_LONG_LOCK_FREE != 0 \ - && ATOMIC_LONG_LOCK_FREE != 1 && ATOMIC_LONG_LOCK_FREE != 2 -# error "ATOMIC_LONG_LOCK_FREE must be 0, 1, or 2" -# endif #endif #ifndef ATOMIC_LLONG_LOCK_FREE # error "ATOMIC_LLONG_LOCK_FREE must be a macro" -#else -# if ATOMIC_LLONG_LOCK_FREE != 0 \ - && ATOMIC_LLONG_LOCK_FREE != 1 && ATOMIC_LLONG_LOCK_FREE != 2 -# error "ATOMIC_LLONG_LOCK_FREE must be 0, 1, or 2" -# endif #endif #ifndef ATOMIC_FLAG_INIT @@ -101,4 +59,41 @@ namespace gnu #ifndef ATOMIC_VAR_INIT #error "ATOMIC_VAR_INIT_must_be_a_macro" #endif + + +extern void abort(void); + +main () +{ + if (ATOMIC_CHAR_LOCK_FREE != 0 && ATOMIC_CHAR_LOCK_FREE != 1 + && ATOMIC_CHAR_LOCK_FREE != 2) + abort (); + + if (ATOMIC_CHAR16_T_LOCK_FREE != 0 && ATOMIC_CHAR16_T_LOCK_FREE != 1 + && ATOMIC_CHAR16_T_LOCK_FREE != 2) + abort (); + + if (ATOMIC_CHAR32_T_LOCK_FREE != 0 && ATOMIC_CHAR32_T_LOCK_FREE != 1 + && ATOMIC_CHAR32_T_LOCK_FREE != 2) + abort (); + + if (ATOMIC_WCHAR_T_LOCK_FREE != 0 && ATOMIC_WCHAR_T_LOCK_FREE != 1 + && ATOMIC_WCHAR_T_LOCK_FREE != 2) + abort (); + + if (ATOMIC_SHORT_LOCK_FREE != 0 && ATOMIC_SHORT_LOCK_FREE != 1 + && ATOMIC_SHORT_LOCK_FREE != 2) + abort (); + + if (ATOMIC_INT_LOCK_FREE != 0 && ATOMIC_INT_LOCK_FREE != 1 + && ATOMIC_INT_LOCK_FREE != 2) + abort (); + + if (ATOMIC_LONG_LOCK_FREE != 0 && ATOMIC_LONG_LOCK_FREE != 1 + && ATOMIC_LONG_LOCK_FREE != 2) + abort (); + + if (ATOMIC_LLONG_LOCK_FREE != 0 && ATOMIC_LLONG_LOCK_FREE != 1 + && ATOMIC_LLONG_LOCK_FREE != 2) + abort (); } diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/3.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/3.cc new file mode 100644 index 00000000000..24ca72085fc --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/3.cc @@ -0,0 +1,56 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// LWG 2067. packaged_task should have deleted copy c'tor with const parameter + +#include <future> +#include <thread> +#include <testsuite_hooks.h> + +template<typename F> +std::future<typename std::result_of<F()>::type> spawn_task(F f) +{ + typedef typename std::result_of<F()>::type result_type; + std::packaged_task<result_type()> task(std::move(f)); + std::future<result_type> res(task.get_future()); + std::thread(std::move(task)).detach(); + return res; +} + +int get_res() +{ + return 42; +} + +void test01() +{ + auto f = spawn_task(get_res); + VERIFY( f.get() == get_res() ); +} + +int main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc new file mode 100644 index 00000000000..40d30705a63 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc @@ -0,0 +1,40 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// Test that packaged_task can be default-constructed or move-constructed +// in a context that does uses-allocator construction. + +#include <future> +#include <memory> +#include <tuple> + +using std::packaged_task; +using std::allocator_arg; +using std::allocator; +using std::tuple; + +typedef packaged_task<void()> task; +allocator<task> a; + +tuple<task> t1{ allocator_arg, a }; +tuple<task> t2{ allocator_arg, a, task{} }; diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/alloc2.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/alloc2.cc new file mode 100644 index 00000000000..a22fd203438 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/cons/alloc2.cc @@ -0,0 +1,42 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// Test that promise can be default-constructed or move-constructed +// in a context that does uses-allocator construction. + +#include <future> +#include <memory> +#include <tuple> + +using std::promise; +using std::allocator_arg; +using std::allocator; +using std::tuple; + +typedef promise<int> p; +typedef promise<int&> pr; +typedef promise<void> pv; +allocator<p> a; + +tuple<p, pr, pv> t1{ allocator_arg, a }; +tuple<p, pr, pv> t2{ allocator_arg, a, p{}, pr{}, pv{} }; diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in index 37e8a3cf675..af161ea5d26 100644 --- a/libstdc++-v3/testsuite/Makefile.in +++ b/libstdc++-v3/testsuite/Makefile.in @@ -213,7 +213,6 @@ glibcxx_builddir = @glibcxx_builddir@ glibcxx_localedir = @glibcxx_localedir@ glibcxx_prefixdir = @glibcxx_prefixdir@ glibcxx_srcdir = @glibcxx_srcdir@ -glibcxx_thread_h = @glibcxx_thread_h@ glibcxx_toolexecdir = @glibcxx_toolexecdir@ glibcxx_toolexeclibdir = @glibcxx_toolexeclibdir@ gxx_include_dir = @gxx_include_dir@ @@ -253,6 +252,7 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +toplevel_builddir = @toplevel_builddir@ toplevel_srcdir = @toplevel_srcdir@ AUTOMAKE_OPTIONS = nostdinc RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir diff --git a/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc b/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc index 4e2d071b833..c6e6feac6c0 100644 --- a/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc +++ b/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc @@ -25,4 +25,4 @@ #include <vector> -// { dg-error "multiple inlined namespaces" "" { target *-*-* } 258 } +// { dg-error "multiple inlined namespaces" "" { target *-*-* } 263 } diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/char/pop_back.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/char/pop_back.cc new file mode 100644 index 00000000000..4dfa2f6fed8 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/char/pop_back.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 21.4.6.5 basic_string::pop_back +// { dg-options "-std=gnu++0x" } + +#include <ext/vstring.h> +#include <testsuite_hooks.h> + +template<typename StrT> +int test01() +{ + bool test __attribute__((unused)) = true; + + const StrT cstr("Badger"); + StrT str = cstr; + str.pop_back(); + VERIFY( str.size() == cstr.size() - 1 ); + + str += cstr.back(); + VERIFY( str == cstr ); + + return test; +} + +int main() +{ + test01<__gnu_cxx::__sso_string>(); + test01<__gnu_cxx::__rc_string>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc new file mode 100644 index 00000000000..ae607b61de3 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 21.4.6.5 basic_string::pop_back +// { dg-options "-std=gnu++0x" } + +#include <ext/vstring.h> +#include <testsuite_hooks.h> + +template<typename StrT> +int test01() +{ + bool test __attribute__((unused)) = true; + + const StrT cstr(L"Badger"); + StrT str = cstr; + str.pop_back(); + VERIFY( str.size() == cstr.size() - 1 ); + + str += cstr.back(); + VERIFY( str == cstr ); + + return test; +} + +int main() +{ + test01<__gnu_cxx::__wsso_string>(); + test01<__gnu_cxx::__wrc_string>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index b510c06126f..e4191925546 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -1673,13 +1673,12 @@ proc check_v3_target_nprocs { } { set f [open $src "w"] puts $f "#include <bits/c++config.h>" puts $f "#if defined(_GLIBCXX_USE_GET_NPROCS)" - puts $f "#elif defined(_GLIBCXX_USE_SYSCONF)" - puts $f "# include <unistd.h>" - puts $f "# if !defined(_SC_NPROCESSORS_ONLN)" - puts $f "# error No sysconf option" - puts $f "# endif" + puts $f "#elif defined(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP)" + puts $f "#elif defined(_GLIBCXX_USE_SYSCTL_HW_NCPU)" + puts $f "#elif defined(_GLIBCXX_USE_SC_NPROCESSORS_ONLN)" + puts $f "#elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)" puts $f "#else" - puts $f "# error No get_nprocs or sysconf" + puts $f "# error hardware_concurrency not implemented" puts $f "#endif" close $f diff --git a/libstdc++-v3/testsuite/performance/23_containers/insert_erase/41975.cc b/libstdc++-v3/testsuite/performance/23_containers/insert_erase/41975.cc index 30fc105c272..a5dae41dc60 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/insert_erase/41975.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/insert_erase/41975.cc @@ -17,56 +17,167 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -#include <cassert> +#include <sstream> #include <unordered_set> #include <testsuite_performance.h> -int main() +namespace { - using namespace __gnu_test; + // Bench using an unordered_set<int>. Hash functor for int is quite + // predictable so it helps bench very specific use cases. + template<bool use_cache> + void bench() + { + using namespace __gnu_test; + std::ostringstream ostr; + ostr << "unordered_set<int> " << (use_cache ? "with" : "without") + << " cache"; + const std::string desc = ostr.str(); + + time_counter time; + resource_counter resource; + + const int nb = 200000; + start_counters(time, resource); + + std::__unordered_set<int, std::hash<int>, std::equal_to<int>, + std::allocator<int>, use_cache> us; + for (int i = 0; i != nb; ++i) + us.insert(i); + + stop_counters(time, resource); + ostr.str(""); + ostr << desc << ": first insert"; + report_performance(__FILE__, ostr.str().c_str(), time, resource); + + start_counters(time, resource); + + // Here is the worst erase use case when hashtable implementation was + // something like vector<forward_list<>>. Erasing from the end was very + // costly because we need to return the iterator following the erased + // one, as the hashtable is getting emptier at each step there are + // more and more empty bucket to loop through to reach the end of the + // container and find out that it was in fact the last element. + for (int j = nb - 1; j >= 0; --j) + { + auto it = us.find(j); + if (it != us.end()) + us.erase(it); + } - time_counter time; - resource_counter resource; + stop_counters(time, resource); + ostr.str(""); + ostr << desc << ": erase from iterator"; + report_performance(__FILE__, ostr.str().c_str(), time, resource); - start_counters(time, resource); + start_counters(time, resource); - std::unordered_set<int> us; - for (int i = 0; i != 5000000; ++i) - us.insert(i); + // This is a worst insertion use case for the current implementation as + // we insert an element at the begining of the hashtable and then we + // insert starting at the end so that each time we need to seek up to the + // first bucket to find the first non-empty one. + us.insert(0); + for (int i = nb - 1; i >= 0; --i) + us.insert(i); - stop_counters(time, resource); - report_performance(__FILE__, "Container generation", time, resource); + stop_counters(time, resource); + ostr.str(""); + ostr << desc << ": second insert"; + report_performance(__FILE__, ostr.str().c_str(), time, resource); - start_counters(time, resource); + start_counters(time, resource); - for (int j = 100; j != 0; --j) + for (int j = nb - 1; j >= 0; --j) + us.erase(j); + + stop_counters(time, resource); + ostr.str(""); + ostr << desc << ": erase from key"; + report_performance(__FILE__, ostr.str().c_str(), time, resource); + } + + // Bench using unordered_set<string> that show how important it is to cache + // hash code as computing string hash code is quite expensive compared to + // computing it for int. + template<bool use_cache> + void bench_str() { - auto it = us.begin(); - while (it != us.end()) + using namespace __gnu_test; + std::ostringstream ostr; + ostr << "unordered_set<string> " << (use_cache ? "with" : "without") + << " cache"; + const std::string desc = ostr.str(); + + time_counter time; + resource_counter resource; + + const int nb = 200000; + // First generate once strings that are going to be used throughout the + // bench: + std::vector<std::string> strs; + strs.reserve(nb); + for (int i = 0; i != nb; ++i) + { + ostr.str(""); + ostr << "string #" << i; + strs.push_back(ostr.str()); + } + + start_counters(time, resource); + + std::__unordered_set<std::string, std::hash<std::string>, + std::equal_to<std::string>, + std::allocator<std::string>, use_cache> us; + for (int i = 0; i != nb; ++i) + us.insert(strs[i]); + + stop_counters(time, resource); + ostr.str(""); + ostr << desc << ": first insert"; + report_performance(__FILE__, ostr.str().c_str(), time, resource); + + start_counters(time, resource); + + for (int j = nb - 1; j >= 0; --j) { - if ((*it % j) == 0) - it = us.erase(it); - else - ++it; + auto it = us.find(strs[j]); + if (it != us.end()) + us.erase(it); } - } - stop_counters(time, resource); - report_performance(__FILE__, "Container erase", time, resource); + stop_counters(time, resource); + ostr.str(""); + ostr << desc << ": erase from iterator"; + report_performance(__FILE__, ostr.str().c_str(), time, resource); - start_counters(time, resource); + start_counters(time, resource); - us.insert(0); + us.insert(strs[0]); + for (int i = nb - 1; i >= 0; --i) + us.insert(strs[i]); - for (int i = 0; i != 500; ++i) - { - auto it = us.begin(); - ++it; - assert( it == us.end() ); - } + stop_counters(time, resource); + ostr.str(""); + ostr << desc << ": second insert"; + report_performance(__FILE__, ostr.str().c_str(), time, resource); + + start_counters(time, resource); + + for (int j = nb - 1; j >= 0; --j) + us.erase(strs[j]); - stop_counters(time, resource); - report_performance(__FILE__, "Container iteration", time, resource); + stop_counters(time, resource); + ostr.str(""); + ostr << desc << ": erase from key"; + report_performance(__FILE__, ostr.str().c_str(), time, resource); + } +} +int main() +{ + bench<false>(); + bench<true>(); + bench_str<false>(); + bench_str<true>(); return 0; } |