From 1b97f18e5f037d40a59f2dab9a32037b7a735f96 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 17 Dec 2023 08:50:47 +0000 Subject: [PATCH] compiler: bring the unreachable macro in line with C23 Signed-off-by: Yuxuan Shui --- src/c2.c | 2 +- src/compiler.h | 10 ++++++---- src/utils.c | 2 +- src/win.c | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/c2.c b/src/c2.c index d82448aa..7f1f80e0 100644 --- a/src/c2.c +++ b/src/c2.c @@ -1336,7 +1336,7 @@ static xcb_atom_t c2_get_atom_type(const c2_l_t *pleaf) { case C2_L_TDRAWABLE: return XCB_ATOM_DRAWABLE; default: assert(0); break; } - unreachable; + unreachable(); } /** diff --git a/src/compiler.h b/src/compiler.h index 76326707..af8fb831 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -101,10 +101,12 @@ # endif #endif -#if defined(__GNUC__) || defined(__clang__) -# define unreachable __builtin_unreachable() -#else -# define unreachable do {} while(0) +#ifndef unreachable +# if defined(__GNUC__) || defined(__clang__) +# define unreachable() __builtin_unreachable() +# else +# define unreachable() do {} while(0) +# endif #endif #ifndef __has_include diff --git a/src/utils.c b/src/utils.c index d26afa33..5709fa21 100644 --- a/src/utils.c +++ b/src/utils.c @@ -30,7 +30,7 @@ void report_allocation_failure(const char *func, const char *file, unsigned int ssize_t _ attr_unused = writev(STDERR_FILENO, v, ARR_SIZE(v)); abort(); - unreachable; + unreachable(); } /// diff --git a/src/win.c b/src/win.c index bd19b3d4..6dccbed6 100644 --- a/src/win.c +++ b/src/win.c @@ -2433,7 +2433,7 @@ bool win_check_fade_finished(session_t *ps, struct managed_win *w) { case WSTATE_DESTROYING: destroy_win_finish(ps, &w->base); return true; case WSTATE_MAPPING: map_win_finish(w); return false; case WSTATE_FADING: w->state = WSTATE_MAPPED; break; - default: unreachable; + default: unreachable(); } }