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/packaged_task/cons/1.cc | 53 ++++++++++++++++++ .../testsuite/30_threads/packaged_task/cons/2.cc | 64 ++++++++++++++++++++++ .../30_threads/packaged_task/cons/alloc.cc | 52 ++++++++++++++++++ .../30_threads/packaged_task/cons/assign_neg.cc | 35 ++++++++++++ .../30_threads/packaged_task/cons/copy_neg.cc | 34 ++++++++++++ .../30_threads/packaged_task/cons/move.cc | 49 +++++++++++++++++ .../30_threads/packaged_task/cons/move_assign.cc | 49 +++++++++++++++++ .../30_threads/packaged_task/members/get_future.cc | 56 +++++++++++++++++++ .../packaged_task/members/get_future2.cc | 58 ++++++++++++++++++++ .../30_threads/packaged_task/members/invoke.cc | 49 +++++++++++++++++ .../30_threads/packaged_task/members/invoke2.cc | 57 +++++++++++++++++++ .../30_threads/packaged_task/members/invoke3.cc | 61 +++++++++++++++++++++ .../30_threads/packaged_task/members/invoke4.cc | 53 ++++++++++++++++++ .../30_threads/packaged_task/members/invoke5.cc | 51 +++++++++++++++++ .../30_threads/packaged_task/members/reset.cc | 63 +++++++++++++++++++++ .../30_threads/packaged_task/members/reset2.cc | 54 ++++++++++++++++++ .../30_threads/packaged_task/members/swap.cc | 49 +++++++++++++++++ .../30_threads/packaged_task/members/valid.cc | 47 ++++++++++++++++ .../requirements/explicit_instantiation.cc | 34 ++++++++++++ .../packaged_task/requirements/typedefs.cc | 31 +++++++++++ 20 files changed, 999 insertions(+) create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/members/valid.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/30_threads/packaged_task/requirements/typedefs.cc (limited to 'libstdc++-v3/testsuite/30_threads/packaged_task') diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc new file mode 100644 index 000000000..b6ea49253 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc @@ -0,0 +1,53 @@ +// { 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, 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 +// . + + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::packaged_task; + using namespace __gnu_test; + + packaged_task p1; + VERIFY( !p1.valid() ); + packaged_task p2; + VERIFY( !p2.valid() ); + packaged_task p3; + VERIFY( !p3.valid() ); + packaged_task p4; + VERIFY( !p4.valid() ); + packaged_task p5; + VERIFY( !p5.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc new file mode 100644 index 000000000..9dc975790 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc @@ -0,0 +1,64 @@ +// { 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, 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 +// . + + +#include +#include +#include + +using namespace __gnu_test; + +int f1() { return 0; } +int& f2() { static int i; return i; } +void f3() { } +ClassType f4() { return ClassType(); } + +struct Derived : AbstractClass { + void rotate(int) { } + Derived& operator()(int i) { rotate(i); return *this; } +} f5; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::packaged_task; + + packaged_task p1(f1); + VERIFY( p1.valid() ); + packaged_task p2(f2); + VERIFY( p2.valid() ); + packaged_task p3(f3); + VERIFY( p3.valid() ); + packaged_task p4(f4); + VERIFY( p4.valid() ); + packaged_task p5(f5); + VERIFY( p5.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc new file mode 100644 index 000000000..531871417 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.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) 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 even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General 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 + +int f() { return 5; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + using std::packaged_task; + using std::allocator_arg; + using __gnu_test::uneq_allocator; + + uneq_allocator alloc(99); + + packaged_task p1(allocator_arg, alloc, f); + VERIFY( p1.valid() ); + p1(); + VERIFY( p1.get_future().get() == 5 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc new file mode 100644 index 000000000..414c861cc --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/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::packaged_task p1; + std::packaged_task p2; + p1 = p2; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc new file mode 100644 index 000000000..93b082194 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/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::packaged_task p1; + std::packaged_task p2(p1); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc new file mode 100644 index 000000000..599caf909 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc @@ -0,0 +1,49 @@ +// { 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, 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 +// . + + +#include +#include + +int f1() { return 0; } + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + // move + packaged_task p1(f1); + packaged_task p2(std::move(p1)); + VERIFY( !p1.valid() ); + VERIFY( p2.valid() ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc new file mode 100644 index 000000000..1c5dfc3b9 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc @@ -0,0 +1,49 @@ +// { 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, 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 +// . + + +#include +#include + +int gen() { return 0; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + // move assign + std::packaged_task p1; + std::packaged_task p2(gen); + p1 = std::move(p2); + VERIFY( p1.valid() ); + VERIFY( !p2.valid() ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.cc new file mode 100644 index 000000000..b44891be8 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.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 + +int& inc(int& i) { return ++i; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task p1(inc); + std::future f1 = p1.get_future(); + + VERIFY( f1.valid() ); + VERIFY( !f1.wait_for(std::chrono::milliseconds(1)) ); + + int i1 = 0; + + p1(i1); + + int& i2 = f1.get(); + + VERIFY( &i1 == &i2 ); + VERIFY( i1 == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc new file mode 100644 index 000000000..5c6d67b97 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc @@ -0,0 +1,58 @@ +// { 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 + +int& inc(int& i) { return ++i; } + +void test01() +{ + bool test = false; + + std::packaged_task p1(inc); + p1.get_future(); + + try + { + p1.get_future(); + VERIFY( false ); + } + catch (const std::future_error& e) + { + VERIFY( e.code() == std::future_errc::future_already_retrieved ); + test = true; + } + + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc new file mode 100644 index 000000000..238568fe3 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc @@ -0,0 +1,49 @@ +// { 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, 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 +// . + + +#include +#include + +int zero() { return 0; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task p1(zero); + std::future f1 = p1.get_future(); + + p1(); + + VERIFY( p1.valid() ); + VERIFY( f1.get() == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.cc new file mode 100644 index 000000000..e29852c48 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.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 + +bool odd(unsigned i) { return i%2; } + +void test01() +{ + bool test = false; + + std::packaged_task p1(odd); + + p1(5); + + try + { + p1(4); + } + catch (const std::future_error& e) + { + VERIFY( e.code() == std::future_errc::promise_already_satisfied ); + test = true; + } + + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc new file mode 100644 index 000000000..7ae6106a2 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc @@ -0,0 +1,61 @@ +// { 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 + +int& inc(int& i) { ++i; return i; } + +void test01() +{ + bool test = false; + + std::packaged_task p1(inc); + + int i1 = 0; + p1(i1); + + VERIFY( i1 == 1 ); + + try + { + p1(i1); + } + catch (const std::future_error& e) + { + VERIFY( e.code() == std::future_errc::promise_already_satisfied ); + test = true; + } + + VERIFY( i1 == 1 ); + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc new file mode 100644 index 000000000..6f0013f30 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc @@ -0,0 +1,53 @@ +// { 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 thrower() { throw 0; } + +void test01() +{ + bool test = false; + + std::packaged_task p1(thrower); + std::future f1 = p1.get_future(); + + p1(); + + try { + f1.get(); + } catch (int) { + test = true; + } + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc new file mode 100644 index 000000000..925dc108f --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc @@ -0,0 +1,51 @@ +// { 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 noop() { } +void waiter(std::shared_future f) { f.wait(); } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task p1(noop); + std::shared_future f1(p1.get_future()); + std::thread t1(waiter, f1); + + p1(); + + t1.join(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc new file mode 100644 index 000000000..01a06d6a3 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc @@ -0,0 +1,63 @@ +// { 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, 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 +// . + + +#include +#include +#include + +int zero() { return 0; } + +void test01() +{ + bool test = false; + using namespace std; + + packaged_task p1(zero); + future f1 = p1.get_future(); + + p1.reset(); + VERIFY( p1.valid() ); + + future f2 = p1.get_future(); + + try + { + f1.get(); + } + catch (future_error& e) + { + VERIFY( e.code() == make_error_code(future_errc::broken_promise) ); + test = true; + } + + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc new file mode 100644 index 000000000..2fac36637 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc @@ -0,0 +1,54 @@ +// { 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, 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 +// . + + +#include +#include + +int iota() { static int i = 0; return i++; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task p1(iota); + std::future f1 = p1.get_future(); + + p1(); + p1.reset(); + + VERIFY( p1.valid() ); + VERIFY( f1.get() == 0 ); + + std::future f2 = p1.get_future(); + p1(); + VERIFY( f2.get() == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc new file mode 100644 index 000000000..9055d9837 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc @@ -0,0 +1,49 @@ +// { 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, 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 +// . + + +#include +#include + +int zero() { return 0; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task p1(zero); + std::packaged_task p2; + VERIFY( p1.valid() ); + VERIFY( !p2.valid() ); + p1.swap(p2); + VERIFY( !p1.valid() ); + VERIFY( p2.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/valid.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/valid.cc new file mode 100644 index 000000000..d7f1ed13d --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/valid.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) 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 +// . + + +#include +#include + +int zero() { return 0; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::packaged_task p1; + VERIFY( !p1.valid() ); + + std::packaged_task p2(zero); + VERIFY( p2.valid() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..4d55603c8 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/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::packaged_task; +template class packaged_task; +template class packaged_task; +template class packaged_task; +template class packaged_task; +template class packaged_task; diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/typedefs.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/typedefs.cc new file mode 100644 index 000000000..3c83a3fe7 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/typedefs.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2009 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 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() +{ + // Check for required typedefs + typedef std::packaged_task test_type; + typedef test_type::result_type result_type; +} -- cgit v1.2.3