diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort index 822df215039ae..3c9cba824ce0b 100644 --- a/libcxx/include/__verbose_abort +++ b/libcxx/include/__verbose_abort @@ -29,9 +29,10 @@ extern "C" void abort(); _LIBCPP_BEGIN_NAMESPACE_STD -_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) _LIBCPP_HIDE_FROM_ABI inline +_LIBCPP_NORETURN _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) _LIBCPP_HIDE_FROM_ABI inline void __libcpp_verbose_abort(const char *, ...) { - ::abort(); + ::abort(); + __builtin_unreachable(); // never reached, but needed to tell the compiler that the function never returns } _LIBCPP_END_NAMESPACE_STD @@ -40,7 +41,7 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD -_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) +_LIBCPP_NORETURN _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char *__format, ...); _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/test/libcxx/assertions/customize_verbose_abort.backdeployment.pass.cpp b/libcxx/test/libcxx/assertions/customize_verbose_abort.backdeployment.pass.cpp index 45f92bc83a268..15962671a4690 100644 --- a/libcxx/test/libcxx/assertions/customize_verbose_abort.backdeployment.pass.cpp +++ b/libcxx/test/libcxx/assertions/customize_verbose_abort.backdeployment.pass.cpp @@ -9,20 +9,18 @@ // Make sure that we can enable assertions when we back-deploy to older platforms // if we define _LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED. // -// Note that this test isn't really different from customize_handler.pass.cpp when -// run outside of back-deployment scenarios, but we still run it all the time. +// Note that this test isn't really different from customize_verbose_abort.pass.cpp when +// run outside of back-deployment scenarios, but we always want to run this test. // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1 -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED -#include +#include -bool handler_called = false; void std::__libcpp_verbose_abort(char const*, ...) { - handler_called = true; + std::exit(EXIT_SUCCESS); } int main(int, char**) { _LIBCPP_ASSERT(false, "message"); - assert(handler_called); - return 0; + return EXIT_FAILURE; } diff --git a/libcxx/test/libcxx/assertions/customize_verbose_abort.pass.cpp b/libcxx/test/libcxx/assertions/customize_verbose_abort.pass.cpp index 7f956742bbe71..3ee9b7803b709 100644 --- a/libcxx/test/libcxx/assertions/customize_verbose_abort.pass.cpp +++ b/libcxx/test/libcxx/assertions/customize_verbose_abort.pass.cpp @@ -14,15 +14,13 @@ // failures when back-deploying. // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}} -#include +#include -bool handler_called = false; void std::__libcpp_verbose_abort(char const*, ...) { - handler_called = true; + std::exit(EXIT_SUCCESS); } int main(int, char**) { _LIBCPP_ASSERT(false, "message"); - assert(handler_called); - return 0; + return EXIT_FAILURE; } diff --git a/libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp b/libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp index b1dd54cbacd1e..fe7f0389de911 100644 --- a/libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp +++ b/libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp @@ -16,15 +16,13 @@ // failures when back-deploying. // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}} -#include +#include -bool handler_called = false; void std::__libcpp_verbose_abort(char const*, ...) { - handler_called = true; + std::exit(EXIT_SUCCESS); } int main(int, char**) { _LIBCPP_ASSERT(false, "message"); - assert(handler_called); - return 0; + return EXIT_FAILURE; }