diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-08-20 06:06:34 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-19 15:06:34 -0700 |
| commit | f77a5ac9d1547a4394bba4ab8e94d905972c79b7 (patch) | |
| tree | 0d66b3c8386d8cb1e75970c93914fe2a60f03c61 /source/core | |
| parent | 453683bf44f2112719802eaac2b332d49eebd640 (diff) | |
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 <yonghe@outlook.com>
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-common.h | 24 | ||||
| -rw-r--r-- | source/core/slang-signal.cpp | 2 | ||||
| -rw-r--r-- | source/core/slang-signal.h | 2 |
3 files changed, 26 insertions, 2 deletions
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) |
