From f77a5ac9d1547a4394bba4ab8e94d905972c79b7 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 20 Aug 2024 06:06:34 +0800 Subject: Remove using SpvStorageClass values casted into AddressSpace values (#4861) * Remove using SpvStorageClass values casted into AddressSpace values Also removes support for specific storage classes in __target_intrinsic snippets * remove SLANG_RETURN_NEVER macro * squash warnings * Make nonexhaustive switch statement error on gcc * Add SLANG_EXHAUSTIVE_SWITCH_BEGIN/END macros --------- Co-authored-by: Yong He --- source/core/slang-common.h | 24 ++++++++++++++++++++++++ source/core/slang-signal.cpp | 2 +- source/core/slang-signal.h | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'source/core') diff --git a/source/core/slang-common.h b/source/core/slang-common.h index 362a509a7..907bf4593 100644 --- a/source/core/slang-common.h +++ b/source/core/slang-common.h @@ -158,6 +158,30 @@ public: #define UNREACHABLE_RETURN(x) return x; #endif +#if SLANG_GCC +# define SLANG_EXHAUSTIVE_SWITCH_BEGIN \ + _Pragma("GCC diagnostic push"); \ + _Pragma("GCC diagnostic error \"-Wswitch-enum\""); +# define SLANG_EXHAUSTIVE_SWITCH_END \ + _Pragma("GCC diagnostic pop"); +#elif SLANG_CLANG +# define SLANG_EXHAUSTIVE_SWITCH_BEGIN \ + _Pragma("clang diagnostic push"); \ + _Pragma("clang diagnostic error \"-Wswitch-enum\""); +# define SLANG_EXHAUSTIVE_SWITCH_END \ + _Pragma("clang diagnostic pop"); +#elif SLANG_VC +# define SLANG_EXHAUSTIVE_SWITCH_BEGIN \ + _Pragma("warning(push)"); \ + _Pragma("warning(error : 4062)"); +# define SLANG_EXHAUSTIVE_SWITCH_END \ + _Pragma("warning(pop)"); +#else +# define SLANG_EXHAUSTIVE_SWITCH_BEGIN +# define SLANG_EXHAUSTIVE_SWITCH_END +#endif + + // // Use `SLANG_ASSUME(myBoolExpression);` to inform the compiler that the condition is true. // Do not rely on side effects of the condition being performed. diff --git a/source/core/slang-signal.cpp b/source/core/slang-signal.cpp index d8218b379..5f53cba93 100644 --- a/source/core/slang-signal.cpp +++ b/source/core/slang-signal.cpp @@ -36,7 +36,7 @@ String _getMessage(SignalType type, char const* message) // One point of having as a single function is a choke point both for handling (allowing different // handling scenarios) as well as a choke point to set a breakpoint to catch 'signal' types -SLANG_RETURN_NEVER void handleSignal(SignalType type, char const* message) +[[noreturn]] void handleSignal(SignalType type, char const* message) { StringBuilder buf; const char*const typeText = _getSignalTypeAsText(type); diff --git a/source/core/slang-signal.h b/source/core/slang-signal.h index 2151bdcfe..759581ee2 100644 --- a/source/core/slang-signal.h +++ b/source/core/slang-signal.h @@ -18,7 +18,7 @@ enum class SignalType // Note that message can be passed as nullptr for no message. -SLANG_RETURN_NEVER void handleSignal(SignalType type, char const* message); +[[noreturn]] void handleSignal(SignalType type, char const* message); #define SLANG_UNEXPECTED(reason) \ ::Slang::handleSignal(::Slang::SignalType::Unexpected, reason) -- cgit v1.2.3