From 5b9755278927555b18880c138525557b5ee75bd0 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 9 Aug 2022 23:20:48 -0700 Subject: [PATCH 1/6] =?UTF-8?q?verify:=20port=20=E2=80=98assume=E2=80=99?= =?UTF-8?q?=20to=20C23=20non-GCC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lib/verify.h (assume): Use C23's unreachable if available and if GCC and/or MSC primitives are not available. --- ChangeLog | 6 ++++++ lib/verify.h | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0dfcb7cdd7..dcf5ae8266 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2022-08-09 Paul Eggert + + verify: port ‘assume’ to C23 non-GCC + * lib/verify.h (assume): Use C23's unreachable if available + and if GCC and/or MSC primitives are not available. + 2022-08-09 Bruno Haible gnulib-tool.py: Finish implementing option --conditional-dependencies. diff --git a/lib/verify.h b/lib/verify.h index c5c63ae97c..47b6ee661b 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -303,13 +303,16 @@ template # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ()) #elif 1200 <= _MSC_VER # define assume(R) __assume (R) +#elif 202311L <= __STDC_VERSION__ +# include +# define assume(R) ((R) ? (void) 0 : unreachable ()) #elif (defined GCC_LINT || defined lint) && _GL_HAS_BUILTIN_TRAP /* Doing it this way helps various packages when configured with --enable-gcc-warnings, which compiles with -Dlint. It's nicer - when 'assume' silences warnings even with older GCCs. */ + if 'assume' silences warnings with GCC 3.4 through GCC 4.4.7 (2012). */ # define assume(R) ((R) ? (void) 0 : __builtin_trap ()) #else - /* Some tools grok NOTREACHED, e.g., Oracle Studio 12.6. */ + /* Some older tools grok NOTREACHED, e.g., Oracle Studio 12.6 (2017). */ # define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0) #endif -- 2.34.1