Avoid Clang error about throwing _LIBCPP_ASSERT in noexcept function.

This fixes a couple of tests which produced a warning that a 'throw'
occurred in a noexcept function (by way of _LIBCPP_ASSERT). It does
so by hiding the 'throw' across an opaque function boundary.

This fix isn't ideal, since we still have _LIBCPP_ASSERT's in functions
marked noexcept -- and this problem should be addressed in the future.
However, throwing _LIBCPP_ASSERT is really only meant to allow testing
of the assertions, and is not yet ready for general use.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@328265 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2018-03-22 23:01:08 +00:00
parent 111f042e6c
commit 73e00f8321
4 changed files with 25 additions and 25 deletions

View File

@@ -11,6 +11,9 @@
// UNSUPPORTED: libcpp-has-no-threads
// UNSUPPORTED: c++98, c++03
// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
// MODULES_DEFINES: _LIBCPP_DEBUG=0
// <future>
// class promise<R>
@@ -18,9 +21,8 @@
// void set_exception(exception_ptr p);
// Test that a null exception_ptr is diagnosed.
#define _LIBCPP_ASSERT(x, m) ((x) ? ((void)0) : throw 42)
#define _LIBCPP_DEBUG 0
#define _LIBCPP_DEBUG_USE_EXCEPTIONS
#include <future>
#include <exception>
#include <cstdlib>
@@ -29,14 +31,14 @@
int main()
{
typedef std::__libcpp_debug_exception ExType;
{
typedef int T;
std::promise<T> p;
try {
p.set_exception(std::exception_ptr());
assert(false);
} catch (int const& value) {
assert(value == 42);
} catch (ExType const&) {
}
}
{
@@ -45,8 +47,7 @@ int main()
try {
p.set_exception(std::exception_ptr());
assert(false);
} catch (int const& value) {
assert(value == 42);
} catch (ExType const&) {
}
}
}