Skip to content

Commit 455abac

Browse files
committed
Fix issue with -fno-exceptions
1 parent 860bec2 commit 455abac

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

libcxx/include/__exception/exception_ptr.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,19 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
9292
friend _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
9393
};
9494

95+
# if _LIBCPP_HAS_EXCEPTIONS
9596
template <class _Ep>
9697
_LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_explicit(_Ep& __e) _NOEXCEPT {
9798
using _Ep2 = __decay_t<_Ep>;
9899
void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));
99-
# ifdef __wasm__
100+
# ifdef __wasm__
100101
auto __cleanup = [](void* __p) -> void* {
101102
std::__destroy_at(static_cast<_Ep2*>(__p));
102103
return __p;
103104
};
104-
# else
105+
# else
105106
auto __cleanup = [](void* __p) { std::__destroy_at(static_cast<_Ep2*>(__p)); };
106-
# endif
107+
# endif
107108
(void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), __cleanup);
108109

109110
try {
@@ -126,7 +127,6 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_via_throw(_Ep& __e) _NO
126127

127128
template <class _Ep>
128129
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
129-
# if _LIBCPP_HAS_EXCEPTIONS
130130
// Objective-C exceptions are thrown via pointer. When throwing an Objective-C exception,
131131
// Clang generates a call to `objc_exception_throw` instead of the usual `__cxa_throw`.
132132
// That function creates an exception with a special Objective-C typeinfo instead of
@@ -147,12 +147,13 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
147147
# else
148148
return std::__make_exception_ptr_via_throw(__e);
149149
# endif
150-
151-
# else // !LIBCPP_HAS_EXCEPTIONS
152-
((void)__e);
150+
}
151+
# else // !_LIBCPP_HAS_EXCEPTIONS
152+
template <class _Ep>
153+
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT {
153154
std::abort();
154-
# endif
155155
}
156+
# endif // _LIBCPP_HAS_EXCEPTIONS
156157

157158
#else // _LIBCPP_ABI_MICROSOFT
158159

libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.objc.pass.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// throwing an exception created via `std::make_exception_ptr`.
1111
// See http://llvm.org/PR135089.
1212

13+
// UNSUPPORTED: no-exceptions
1314
// UNSUPPORTED: c++03
1415

1516
// This test requires the Objective-C ARC, which is (only?) available on Darwin

0 commit comments

Comments
 (0)