| ... | ... | @@ -43,15 +43,21 @@ ATTRIBUTE_NORETURN |
| 43 | 43 | ATTRIBUTE_PRINTF(1, 2) |
| 44 | 44 | void zig_panic(const char *format, ...); |
| 45 | 45 | |
| 46 | static inline void zig_assert(bool ok, const char *file, int line, const char *func) { |
| 47 | if (!ok) { |
| 48 | zig_panic("Assertion failed at %s:%d in %s. This is a bug in the Zig compiler.", file, line, func); |
| 49 | } |
| 50 | } |
| 51 | |
| 46 | 52 | #ifdef _WIN32 |
| 47 | 53 | #define __func__ __FUNCTION__ |
| 48 | 54 | #endif |
| 49 | 55 | |
| 50 | | #define zig_unreachable() zig_panic("unreachable: %s:%s:%d", __FILE__, __func__, __LINE__) |
| 56 | #define zig_unreachable() zig_panic("Unreachable at %s:%d in %s. This is a bug in the Zig compiler.", __FILE__, __LINE__, __func__) |
| 51 | 57 | |
| 52 | 58 | // Assertions in stage1 are always on, and they call zig @panic. |
| 53 | 59 | #undef assert |
| 54 | | void assert(bool ok); |
| 60 | #define assert(ok) zig_assert(ok, __FILE__, __LINE__, __func__) |
| 55 | 61 | |
| 56 | 62 | #if defined(_MSC_VER) |
| 57 | 63 | static inline int clzll(unsigned long long mask) { |