From: Paul Eggert <eggert@cs.ucla.edu> Date: Wed, 10 Aug 2022 06:20:48 +0000 (-0700) Subject: verify: port ‘assume’ to C23 non-GCC X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=7abc0e1bf1dd18c48674663dd384d345d506421c;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 3392215a74..28aa4b1f60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2022-08-09 Paul Eggert <eggert@cs.ucla.edu> + + 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-07-31 Bruno Haible <bruno@clisp.org> gendocs.sh: Fix error when invoking 'perl' (regression 2022-07-23). 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