Fix clang warning -Winvalid-noreturn on Windows

This commit is contained in:
Roelf-Jilling 2018-11-16 14:28:56 +01:00
parent 1b15a73942
commit 2238c4760e

View File

@ -27,7 +27,7 @@
#if defined(__clang__) #if defined(__clang__)
#define GSL_SUPPRESS(x) [[gsl::suppress("x")]] #define GSL_SUPPRESS(x) [[gsl::suppress("x")]]
#else #else
#if defined (_MSC_VER) #if defined(_MSC_VER)
#define GSL_SUPPRESS(x) [[gsl::suppress(x)]] #define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
#else #else
#define GSL_SUPPRESS(x) #define GSL_SUPPRESS(x)
@ -98,7 +98,7 @@ namespace details
#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) #if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND)
typedef void (__cdecl *terminate_handler)(); typedef void (__cdecl *terminate_handler)();
GSL_SUPPRESS(f.6) // NO-FORMAT: attribute GSL_SUPPRESS(f.6) // NO-FORMAT: attribute
[[noreturn]] inline void __cdecl default_terminate_handler() [[noreturn]] inline void __cdecl default_terminate_handler()
{ {
@ -113,19 +113,20 @@ namespace details
#endif #endif
[[noreturn]] inline void terminate() noexcept
{
#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) #if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND)
(*gsl::details::get_terminate_handler())(); inline void terminate() noexcept { (*gsl::details::get_terminate_handler())(); }
#else #else
std::terminate(); [[noreturn]] inline void terminate() noexcept { std::terminate(); }
#endif #endif
}
#if defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION) #if defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION)
template <typename Exception> template <typename Exception>
#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND)
void throw_exception(Exception&&) noexcept
#else
[[noreturn]] void throw_exception(Exception&&) noexcept [[noreturn]] void throw_exception(Exception&&) noexcept
#endif
{ {
gsl::details::terminate(); gsl::details::terminate();
} }