diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2022-08-09 23:20:48 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2022-08-10 00:22:08 -0700 |
commit | 5b9755278927555b18880c138525557b5ee75bd0 (patch) | |
tree | 5cf53e365c4fbe12f109718918be8210fd1f4f85 /lib | |
parent | 62fa8fc7b2c9db14d8c24d6ec5beedecb27b4802 (diff) | |
download | gnulib-5b9755278927555b18880c138525557b5ee75bd0.tar.gz |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/verify.h | 7 |
1 files changed, 5 insertions, 2 deletions
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 <int w> # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ()) #elif 1200 <= _MSC_VER # define assume(R) __assume (R) +#elif 202311L <= __STDC_VERSION__ +# include <stddef.h> +# 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 |