Author: ericwf Date: Thu Mar 22 16:01:08 2018 New Revision: 328265 URL: http://llvm.org/viewvc/llvm-project?rev=328265&view=rev Log: 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. Modified: libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp libcxx/trunk/utils/libcxx/test/config.py Modified: libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp?rev=328265&r1=328264&r2=328265&view=diff ============================================================================== --- libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp (original) +++ libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp Thu Mar 22 16:01:08 2018 @@ -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::filesy 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&) {} } } Modified: libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp?rev=328265&r1=328264&r2=328265&view=diff ============================================================================== --- libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp (original) +++ libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp Thu Mar 22 16:01:08 2018 @@ -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&) { } } } Modified: libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp?rev=328265&r1=328264&r2=328265&view=diff ============================================================================== --- libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp (original) +++ libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp Thu Mar 22 16:01:08 2018 @@ -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) { } } } Modified: libcxx/trunk/utils/libcxx/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=328265&r1=328264&r2=328265&view=diff ============================================================================== --- libcxx/trunk/utils/libcxx/test/config.py (original) +++ libcxx/trunk/utils/libcxx/test/config.py Thu Mar 22 16:01:08 2018 @@ -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. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits