From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../testsuite/30_threads/promise/cons/1.cc | 46 +++++++++ .../testsuite/30_threads/promise/cons/alloc.cc | 47 +++++++++ .../30_threads/promise/cons/assign_neg.cc | 35 +++++++ .../testsuite/30_threads/promise/cons/copy_neg.cc | 34 +++++++ .../testsuite/30_threads/promise/cons/move.cc | 55 +++++++++++ .../30_threads/promise/cons/move_assign.cc | 56 +++++++++++ .../30_threads/promise/members/get_future.cc | 52 ++++++++++ .../30_threads/promise/members/get_future2.cc | 57 +++++++++++ .../30_threads/promise/members/set_exception.cc | 57 +++++++++++ .../30_threads/promise/members/set_exception2.cc | 93 ++++++++++++++++++ .../30_threads/promise/members/set_value.cc | 106 +++++++++++++++++++++ .../30_threads/promise/members/set_value2.cc | 87 +++++++++++++++++ .../30_threads/promise/members/set_value3.cc | 78 +++++++++++++++ .../testsuite/30_threads/promise/members/swap.cc | 46 +++++++++ .../promise/requirements/explicit_instantiation.cc | 34 +++++++ 15 files changed, 883 insertions(+) create mode 100644 libstdc++-v3/testsuite/30_threads/promise/cons/1.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/cons/alloc.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/cons/move.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/members/swap.cc create mode 100644 libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc (limited to 'libstdc++-v3/testsuite/30_threads/promise') diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/1.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/1.cc new file mode 100644 index 000000000..79120b7cd --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/cons/1.cc @@ -0,0 +1,46 @@ +// { 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) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +void test01() +{ + using std::promise; + using namespace __gnu_test; + + promise p1; + promise p2; + promise p3; + promise p4; + promise p5; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/alloc.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/alloc.cc new file mode 100644 index 000000000..0ac560df4 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/cons/alloc.cc @@ -0,0 +1,47 @@ +// { 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) 2010 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 +// . + +#include +#include +#include + +void test01() +{ + using std::promise; + using std::allocator_arg; + using __gnu_test::uneq_allocator; + + uneq_allocator alloc(99); + + promise p1(allocator_arg, alloc); + p1.set_value(5); + VERIFY( p1.get_future().get() == 5 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc new file mode 100644 index 000000000..50b1c6e17 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009, 2010 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 +// . + + +#include + +void test01() +{ + // assign + std::promise p1; + std::promise p2; + p1 = p2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc new file mode 100644 index 000000000..5e43d0b1f --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009, 2010 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 +// . + + +#include + +void test01() +{ + // copy + std::promise p1; + std::promise p2(p1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/move.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/move.cc new file mode 100644 index 000000000..5fc2cae44 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/cons/move.cc @@ -0,0 +1,55 @@ +// { 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) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + // move assign + promise p1; + p1.set_value(3); + promise p2(std::move(p1)); + VERIFY( p2.get_future().get() == 3 ); + try + { + p1.get_future(); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY(e.code() == make_error_code(future_errc::no_state)); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.cc new file mode 100644 index 000000000..5d96e8ffc --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.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) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + // move assign + promise p1; + p1.set_value(3); + promise p2; + p2 = move(p1); + VERIFY( p2.get_future().get() == 3 ); + try + { + p1.get_future(); + VERIFY( false ); + } + catch (future_error& e) + { + VERIFY(e.code() == make_error_code(future_errc::no_state)); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc b/libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc new file mode 100644 index 000000000..b09e302cc --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc @@ -0,0 +1,52 @@ +// { 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) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise p1; + std::future f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + int i1 = 0; + + p1.set_value(i1); + + int& i2 = f1.get(); + + VERIFY( &i1 == &i2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc b/libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc new file mode 100644 index 000000000..cc44fc479 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc @@ -0,0 +1,57 @@ +// { 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) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +void test01() +{ + bool test = false; + using namespace std; + + promise p1; + p1.get_future(); + + try + { + p1.get_future(); + VERIFY( false ); + } + catch (future_error& e) + { + VERIFY(e.code() == make_error_code(future_errc::future_already_retrieved)); + test = true; + } + + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc new file mode 100644 index 000000000..4d2a1ec02 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc @@ -0,0 +1,57 @@ +// { 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) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +void test01() +{ + bool test = false; + + std::promise p1; + std::future f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + p1.set_exception(std::copy_exception(0)); + + try + { + f1.get(); + } + catch (int) + { + test = true; + } + VERIFY( test ); + VERIFY( !f1.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc new file mode 100644 index 000000000..872a4792f --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc @@ -0,0 +1,93 @@ +// { 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) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +void test01() +{ + bool test = false; + + std::promise p1; + std::future f1 = p1.get_future(); + + p1.set_exception(std::copy_exception(0)); + + try + { + p1.set_exception(std::copy_exception(1)); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY(e.code() == + std::make_error_code(std::future_errc::promise_already_satisfied)); + test = true; + } + + try + { + f1.get(); + test = false; + } + catch(int i) + { + VERIFY( i == 0 ); + } + + VERIFY( test ); +} + +void test02() +{ + bool test = false; + + std::promise p1; + std::future f1 = p1.get_future(); + + p1.set_value(2); + + try + { + p1.set_exception(std::copy_exception(0)); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY(e.code() == + std::make_error_code(std::future_errc::promise_already_satisfied)); + test = true; + } + + VERIFY( test ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc new file mode 100644 index 000000000..9d3f8ead3 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc @@ -0,0 +1,106 @@ +// { 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) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise p1; + std::future f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + p1.set_value(0); + + int&& i1 = f1.get(); + + VERIFY( i1 == 0 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + std::promise p1; + std::future f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + p1.set_value(rvalstruct(1)); + + rvalstruct r1(f1.get()); + + VERIFY( !f1.valid() ); + VERIFY( r1.val == 1 ); +} + + +void test03() +{ + bool test __attribute__((unused)) = true; + + std::promise p1; + std::future f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + int i1 = 0; + p1.set_value(i1); + int& i2 = f1.get(); + + VERIFY( !f1.valid() ); + VERIFY( &i1 == &i2 ); +} + +void test04() +{ + bool test __attribute__((unused)) = true; + + std::promise p1; + std::future f1 = p1.get_future(); + + VERIFY( f1.valid() ); + + p1.set_value(); + f1.get(); + + VERIFY( !f1.valid() ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc new file mode 100644 index 000000000..09c8a52fa --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc @@ -0,0 +1,87 @@ +// { 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) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +void test01() +{ + bool test = false; + + std::promise p1; + std::future f1 = p1.get_future(); + + p1.set_value(1); + + try + { + p1.set_value(2); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY(e.code() == + std::make_error_code(std::future_errc::promise_already_satisfied)); + test = true; + } + + VERIFY( f1.wait_for(std::chrono::milliseconds(1)) ); + VERIFY( f1.get() == 1 ); + VERIFY( test ); +} + +void test02() +{ + bool test = false; + + std::promise p1; + std::future f1 = p1.get_future(); + + p1.set_value(3); + + try + { + p1.set_exception(std::copy_exception(4)); + VERIFY( false ); + } + catch (std::future_error& e) + { + VERIFY(e.code() == + std::make_error_code(std::future_errc::promise_already_satisfied)); + test = true; + } + + VERIFY( f1.wait_for(std::chrono::milliseconds(1)) ); + VERIFY( f1.get() == 3 ); + VERIFY( test ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc new file mode 100644 index 000000000..5dabff97d --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc @@ -0,0 +1,78 @@ +// { 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) 2009, 2010 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 +// . + +#include +#include + + +// Test promise::set_value() for deadlock by checking if the state is ready +// during construction and destruction of the associated state. + +struct tester +{ + tester(int); + tester(const tester&); + tester() = delete; + tester& operator=(const tester&); +}; + +std::promise pglobal; +std::future fglobal = pglobal.get_future(); + +tester::tester(int) +{ + bool test __attribute__((unused)) = true; + VERIFY (!fglobal.wait_for(std::chrono::milliseconds(1))); +} + +tester::tester(const tester&) +{ + bool test __attribute__((unused)) = true; + // if this copy happens while a mutex is locked next line could deadlock: + VERIFY (!fglobal.wait_for(std::chrono::milliseconds(1))); +} + +tester& tester::operator=(const tester&) +{ + bool test __attribute__((unused)) = true; + // if this copy happens while a mutex is locked next line could deadlock: + VERIFY (!fglobal.wait_for(std::chrono::milliseconds(1))); + return *this; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + + pglobal.set_value( tester(1) ); + + VERIFY( fglobal.wait_for(std::chrono::milliseconds(1)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/swap.cc b/libstdc++-v3/testsuite/30_threads/promise/members/swap.cc new file mode 100644 index 000000000..b27ee2be7 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/members/swap.cc @@ -0,0 +1,46 @@ +// { 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) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::promise p1; + std::promise p2; + p1.set_value(1); + p1.swap(p2); + VERIFY( !p1.get_future().wait_for(std::chrono::milliseconds(1)) ); + VERIFY( p2.get_future().wait_for(std::chrono::milliseconds(1)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..903b3ab14 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +using namespace __gnu_test; +using std::promise; +template class promise; +template class promise; +template class promise; +template class promise; +template class promise; -- cgit v1.2.3