Adds solidity::util::unreachable() helper function.

This commit is contained in:
Christian Parpart 2022-06-07 15:41:15 +02:00
parent 87f5865fb0
commit 927da20ce4

View File

@ -40,6 +40,28 @@ namespace solidity::util
#define ETH_FUNC __func__ #define ETH_FUNC __func__
#endif #endif
#if defined(__GNUC__)
// GCC 4.8+, Clang, Intel and other compilers compatible with GCC (-std=c++0x or above)
[[noreturn]] inline __attribute__((always_inline)) void unreachable()
{
__builtin_unreachable();
}
#elif defined(_MSC_VER) // MSVC
[[noreturn]] __forceinline void unreachable()
{
__assume(false);
}
#else
[[noreturn]] inline void unreachable()
{
solThrow(Exception, "Unreachable");
}
#endif
namespace assertions namespace assertions
{ {