From: Paul Eggert Date: Wed, 10 Aug 2022 06:20:48 +0000 (-0700) Subject: verify: port ‘assume’ to C23 non-GCC X-Git-Tag: v1.0~2133 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=5b9755278927555b18880c138525557b5ee75bd0;p=gnulib.git 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. --- 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