Add an unreachable() macro function that panics if reached

This commit is contained in:
apio 2022-12-18 12:40:28 +01:00
parent a89ae9bed7
commit 23d405bbda
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -1,5 +1,4 @@
#pragma once
#include <luna/Attributes.h>
[[noreturn]] extern bool __check_failed(const char* file, const char* line, const char* func, const char* expr);
@ -23,3 +22,6 @@
__check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, #expr); \
} \
} while (0)
#define unreachable() \
__check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, "Reached unreachable code")