From e269879e0338d709671bb0072ef892aa8af598b4 Mon Sep 17 00:00:00 2001 From: redi Date: Mon, 8 Oct 2018 12:17:58 +0000 Subject: [PATCH] PR libstdc++/87538 Verify fix for std::experimental::not_fn PR libstdc++/87538 * testsuite/experimental/functional/87538.cc: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264922 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 3 ++ .../testsuite/experimental/functional/87538.cc | 48 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 libstdc++-v3/testsuite/experimental/functional/87538.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index aec162913c2..12dee3a273c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,6 +1,9 @@ 2018-10-08 Jonathan Wakely PR libstdc++/87538 + * testsuite/experimental/functional/87538.cc: New test. + + PR libstdc++/87538 * include/std/functional (_Not_fn::operator()): Check value of __is_nothrow_invocable as well. * testsuite/20_util/function_objects/not_fn/87538.cc: New test. diff --git a/libstdc++-v3/testsuite/experimental/functional/87538.cc b/libstdc++-v3/testsuite/experimental/functional/87538.cc new file mode 100644 index 00000000000..1ee9ecd55f3 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/functional/87538.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2018 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 +// . + +// { dg-do run { target c++14 } } + +#include +#include + +struct N { + int operator()(int i) { if (i == 0) throw -1; return i; } +}; + +void +test01() +{ + N n; + auto not_n = std::experimental::not_fn(n); + static_assert( !noexcept(not_n(1)), "can throw" ); + VERIFY(not_n(1) == 0); + int exception = 0; + try { + not_n(0); + } + catch (int e) { + exception = e; + } + VERIFY(exception == -1); +} + +int +main() +{ + test01(); +} -- 2.11.4.GIT