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:
@@ -10,13 +10,15 @@
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
// UNSUPPORTED: libcpp-no-exceptions
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
|
||||
// MODULES_DEFINES: _LIBCPP_DEBUG=0
|
||||
|
||||
// <experimental/filesystem>
|
||||
|
||||
// class path
|
||||
|
||||
#define _LIBCPP_DEBUG 0
|
||||
#define _LIBCPP_ASSERT(cond, msg) ((cond) ? ((void)0) : throw 42)
|
||||
|
||||
#define _LIBCPP_DEBUG_USE_EXCEPTIONS
|
||||
#include <experimental/filesystem>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
@@ -29,17 +31,18 @@ namespace fs = std::experimental::filesystem;
|
||||
|
||||
int main() {
|
||||
using namespace fs;
|
||||
using ExType = std::__libcpp_debug_exception;
|
||||
// Test incrementing/decrementing a singular iterator
|
||||
{
|
||||
path::iterator singular;
|
||||
try {
|
||||
++singular;
|
||||
assert(false);
|
||||
} catch (int) {}
|
||||
} catch (ExType const&) {}
|
||||
try {
|
||||
--singular;
|
||||
assert(false);
|
||||
} catch (int) {}
|
||||
} catch (ExType const&) {}
|
||||
}
|
||||
// Test decrementing the begin iterator
|
||||
{
|
||||
@@ -48,13 +51,13 @@ int main() {
|
||||
try {
|
||||
--it;
|
||||
assert(false);
|
||||
} catch (int) {}
|
||||
} catch (ExType const&) {}
|
||||
++it;
|
||||
++it;
|
||||
try {
|
||||
++it;
|
||||
assert(false);
|
||||
} catch (int) {}
|
||||
} catch (ExType const&) {}
|
||||
}
|
||||
// Test incrementing the end iterator
|
||||
{
|
||||
@@ -63,12 +66,12 @@ int main() {
|
||||
try {
|
||||
++it;
|
||||
assert(false);
|
||||
} catch (int) {}
|
||||
} catch (ExType const&) {}
|
||||
--it;
|
||||
--it;
|
||||
try {
|
||||
--it;
|
||||
assert(false);
|
||||
} catch (int) {}
|
||||
} catch (ExType const&) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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&) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_on_thread_exit(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_at_thread_exit(std::exception_ptr());
|
||||
assert(false);
|
||||
} catch (int const& value) {
|
||||
assert(value == 42);
|
||||
} catch (ExType const& value) {
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -45,8 +47,7 @@ int main()
|
||||
try {
|
||||
p.set_exception_at_thread_exit(std::exception_ptr());
|
||||
assert(false);
|
||||
} catch (int const& value) {
|
||||
assert(value == 42);
|
||||
} catch (ExType const& value) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -918,11 +918,6 @@ class Configuration(object):
|
||||
self.cxx.addWarningFlagIfSupported('-Wno-user-defined-literals')
|
||||
self.cxx.addWarningFlagIfSupported('-Wno-noexcept-type')
|
||||
self.cxx.addWarningFlagIfSupported('-Wno-aligned-allocation-unavailable')
|
||||
# FIXME: Remove this work-around. It is a temporary hack to get the
|
||||
# throwing debug tests passing. For example:
|
||||
# * test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp
|
||||
# * test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
|
||||
self.cxx.addWarningFlagIfSupported("-Wno-exceptions")
|
||||
# These warnings should be enabled in order to support the MSVC
|
||||
# team using the test suite; They enable the warnings below and
|
||||
# expect the test suite to be clean.
|
||||
|
||||
Reference in New Issue
Block a user