From 73e00f8321b13559b3c41f6656686d980fe92fbe Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Thu, 22 Mar 2018 23:01:08 +0000 Subject: [PATCH] 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 --- .../class.path/path.itr/iterator_db.pass.cpp | 19 +++++++++++-------- .../futures.promise/set_exception.pass.cpp | 13 +++++++------ .../set_exception_at_thread_exit.pass.cpp | 13 +++++++------ utils/libcxx/test/config.py | 5 ----- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp b/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp index aea46f10c..b8b7124ad 100644 --- a/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp +++ b/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp @@ -10,13 +10,15 @@ // UNSUPPORTED: c++98, c++03 // UNSUPPORTED: libcpp-no-exceptions +// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS +// MODULES_DEFINES: _LIBCPP_DEBUG=0 + // // class path #define _LIBCPP_DEBUG 0 -#define _LIBCPP_ASSERT(cond, msg) ((cond) ? ((void)0) : throw 42) - +#define _LIBCPP_DEBUG_USE_EXCEPTIONS #include #include #include @@ -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&) {} } } diff --git a/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp b/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp index 9efa597d7..abfbb685d 100644 --- a/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp +++ b/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp @@ -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 + // // class promise @@ -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 #include #include @@ -29,14 +31,14 @@ int main() { + typedef std::__libcpp_debug_exception ExType; { typedef int T; std::promise 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&) { } } } diff --git a/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp b/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp index dca493382..6736bae97 100644 --- a/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp +++ b/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp @@ -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 + // // class promise @@ -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 #include #include @@ -29,14 +31,14 @@ int main() { + typedef std::__libcpp_debug_exception ExType; { typedef int T; std::promise 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) { } } } diff --git a/utils/libcxx/test/config.py b/utils/libcxx/test/config.py index 24bbbd523..2af4a473e 100644 --- a/utils/libcxx/test/config.py +++ b/utils/libcxx/test/config.py @@ -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.