diff --git a/libcxx/include/__format/format_error.h b/libcxx/include/__format/format_error.h --- a/libcxx/include/__format/format_error.h +++ b/libcxx/include/__format/format_error.h @@ -28,6 +28,7 @@ #if _LIBCPP_STD_VER > 17 +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI format_error : public runtime_error { public: _LIBCPP_HIDE_FROM_ABI explicit format_error(const string& __s) @@ -36,6 +37,7 @@ : runtime_error(__s) {} virtual ~format_error() noexcept; }; +#endif _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const char* __s) { diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem --- a/libcxx/include/filesystem +++ b/libcxx/include/filesystem @@ -1683,6 +1683,7 @@ // filesystem_error to work around PR41078. _LIBCPP_AVAILABILITY_FILESYSTEM_POP +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error { public: _LIBCPP_INLINE_VISIBILITY @@ -1734,6 +1735,7 @@ }; shared_ptr<_Storage> __storage_; }; +#endif _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH diff --git a/libcxx/include/future b/libcxx/include/future --- a/libcxx/include/future +++ b/libcxx/include/future @@ -500,6 +500,7 @@ return error_condition(static_cast(__e), future_category()); } +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_FUTURE_ERROR future_error : public logic_error { @@ -513,6 +514,7 @@ future_error(const future_error&) _NOEXCEPT = default; virtual ~future_error() _NOEXCEPT; }; +#endif _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_NO_EXCEPTIONS @@ -1340,10 +1342,12 @@ { if (__state_) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (!__state_->__has_value() && __state_->use_count() > 1) __state_->set_exception(make_exception_ptr( future_error(make_error_code(future_errc::broken_promise)) )); +#endif // _LIBCPP_NO_EXCEPTIONS __state_->__release_shared(); } } @@ -1483,10 +1487,12 @@ { if (__state_) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (!__state_->__has_value() && __state_->use_count() > 1) __state_->set_exception(make_exception_ptr( future_error(make_error_code(future_errc::broken_promise)) )); +#endif // _LIBCPP_NO_EXCEPTIONS __state_->__release_shared(); } } diff --git a/libcxx/include/ios b/libcxx/include/ios --- a/libcxx/include/ios +++ b/libcxx/include/ios @@ -425,6 +425,7 @@ return error_condition(static_cast(__e), iostream_category()); } +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI ios_base::failure : public system_error { @@ -434,6 +435,7 @@ failure(const failure&) _NOEXCEPT = default; virtual ~failure() _NOEXCEPT; }; +#endif _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY void __throw_failure(char const* __msg) { diff --git a/libcxx/include/regex b/libcxx/include/regex --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -980,6 +980,7 @@ } // regex_constants +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI regex_error : public runtime_error { @@ -991,6 +992,7 @@ _LIBCPP_INLINE_VISIBILITY regex_constants::error_type code() const {return __code_;} }; +#endif template _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY diff --git a/libcxx/include/stdexcept b/libcxx/include/stdexcept --- a/libcxx/include/stdexcept +++ b/libcxx/include/stdexcept @@ -73,6 +73,7 @@ namespace std // purposefully not using versioning namespace { +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI logic_error : public exception { @@ -208,6 +209,7 @@ virtual ~underflow_error() _NOEXCEPT; #endif }; +#endif // _LIBCPP_NO_EXCEPTIONS } // std diff --git a/libcxx/include/system_error b/libcxx/include/system_error --- a/libcxx/include/system_error +++ b/libcxx/include/system_error @@ -459,6 +459,7 @@ // system_error +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_TYPE_VIS system_error : public runtime_error { @@ -479,6 +480,7 @@ private: static string __init(const error_code&, string); }; +#endif _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_system_error(int ev, const char* what_arg); diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp --- a/libcxx/src/filesystem/operations.cpp +++ b/libcxx/src/filesystem/operations.cpp @@ -665,6 +665,7 @@ #endif // CLOCK_REALTIME } +#ifndef _LIBCPP_NO_EXCEPTIONS filesystem_error::~filesystem_error() {} void filesystem_error::__create_what(int __num_paths) { @@ -683,6 +684,7 @@ _LIBCPP_UNREACHABLE(); }(); } +#endif static path __do_absolute(const path& p, path* cwd, error_code* ec) { if (ec) diff --git a/libcxx/src/format.cpp b/libcxx/src/format.cpp --- a/libcxx/src/format.cpp +++ b/libcxx/src/format.cpp @@ -12,8 +12,12 @@ #if _LIBCPP_STD_VER > 17 +#ifndef _LIBCPP_NO_EXCEPTIONS + format_error::~format_error() noexcept = default; -#endif //_LIBCPP_STD_VER > 17 +#endif // _LIBCPP_NO_EXCEPTIONS + +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/src/future.cpp b/libcxx/src/future.cpp --- a/libcxx/src/future.cpp +++ b/libcxx/src/future.cpp @@ -71,6 +71,7 @@ return __f; } +#ifndef _LIBCPP_NO_EXCEPTIONS future_error::future_error(error_code __ec) : logic_error(__ec.message()), __ec_(__ec) @@ -80,6 +81,7 @@ future_error::~future_error() noexcept { } +#endif // _LIBCPP_NO_EXCEPTIONS void __assoc_sub_state::__on_zero_shared() noexcept diff --git a/libcxx/src/ios.cpp b/libcxx/src/ios.cpp --- a/libcxx/src/ios.cpp +++ b/libcxx/src/ios.cpp @@ -58,6 +58,8 @@ // ios_base::failure +#ifndef _LIBCPP_NO_EXCEPTIONS + ios_base::failure::failure(const string& msg, const error_code& ec) : system_error(ec, msg) { @@ -72,6 +74,8 @@ { } +#endif // _LIBCPP_NO_EXCEPTIONS + // ios_base locale const ios_base::fmtflags ios_base::boolalpha; diff --git a/libcxx/src/optional.cpp b/libcxx/src/optional.cpp --- a/libcxx/src/optional.cpp +++ b/libcxx/src/optional.cpp @@ -27,6 +27,7 @@ // Even though it no longer exists in a header file _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public std::logic_error { @@ -38,5 +39,6 @@ }; bad_optional_access::~bad_optional_access() noexcept = default; +#endif // _LIBCPP_NO_EXCEPTIONS _LIBCPP_END_NAMESPACE_EXPERIMENTAL diff --git a/libcxx/src/regex.cpp b/libcxx/src/regex.cpp --- a/libcxx/src/regex.cpp +++ b/libcxx/src/regex.cpp @@ -12,6 +12,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_NO_EXCEPTIONS + static const char* make_error_type_string(regex_constants::error_type ecode) @@ -68,6 +70,8 @@ regex_error::~regex_error() throw() {} +#endif // _LIBCPP_NO_EXCEPTIONS + namespace { struct collationnames diff --git a/libcxx/src/string.cpp b/libcxx/src/string.cpp --- a/libcxx/src/string.cpp +++ b/libcxx/src/string.cpp @@ -50,13 +50,17 @@ inline void throw_from_string_out_of_range( const string& func ) { +#ifndef _LIBCPP_NO_EXCEPTIONS throw_helper(func + ": out of range"); +#endif } inline void throw_from_string_invalid_arg( const string& func ) { +#ifndef _LIBCPP_NO_EXCEPTIONS throw_helper(func + ": no conversion"); +#endif } // as_integer diff --git a/libcxx/src/support/runtime/stdexcept_default.ipp b/libcxx/src/support/runtime/stdexcept_default.ipp --- a/libcxx/src/support/runtime/stdexcept_default.ipp +++ b/libcxx/src/support/runtime/stdexcept_default.ipp @@ -19,6 +19,8 @@ namespace std // purposefully not using versioning namespace { +#ifndef _LIBCPP_NO_EXCEPTIONS + logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) {} logic_error::logic_error(const char* msg) : __imp_(msg) {} @@ -59,6 +61,8 @@ overflow_error::~overflow_error() noexcept {} underflow_error::~underflow_error() noexcept {} -#endif +#endif // !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) + +#endif // _LIBCPP_NO_EXCEPTIONS } // namespace std diff --git a/libcxx/src/system_error.cpp b/libcxx/src/system_error.cpp --- a/libcxx/src/system_error.cpp +++ b/libcxx/src/system_error.cpp @@ -228,6 +228,8 @@ // system_error +#ifndef _LIBCPP_NO_EXCEPTIONS + string system_error::__init(const error_code& ec, string what_arg) { @@ -280,6 +282,8 @@ { } +#endif // _LIBCPP_NO_EXCEPTIONS + void __throw_system_error(int ev, const char* what_arg) { diff --git a/libcxxabi/src/stdlib_stdexcept.cpp b/libcxxabi/src/stdlib_stdexcept.cpp --- a/libcxxabi/src/stdlib_stdexcept.cpp +++ b/libcxxabi/src/stdlib_stdexcept.cpp @@ -21,6 +21,8 @@ namespace std // purposefully not using versioning namespace { +#ifndef _LIBCPP_NO_EXCEPTIONS + logic_error::~logic_error() noexcept {} const char* @@ -46,4 +48,6 @@ overflow_error::~overflow_error() noexcept {} underflow_error::~underflow_error() noexcept {} +#endif // _LIBCPP_NO_EXCEPTIONS + } // std