diff options
author | Bruno Haible <bruno@clisp.org> | 2023-03-16 13:45:40 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-03-16 13:45:40 +0100 |
commit | d7630af4363afdbda443c63400473dc135bc858f (patch) | |
tree | 010ed5960786ba276ca7e125222f8a21179bd386 /m4/stddef_h.m4 | |
parent | 90356fd2227dd19317d50b9cf40168ccb15e585c (diff) | |
download | gnulib-d7630af4363afdbda443c63400473dc135bc858f.tar.gz |
stddef: Define 'unreachable', for ISO C 23 compliance.
* lib/verify.h (_GL_HAS_BUILTIN_UNREACHABLE): Don't define if already
defined.
* lib/stddef.in.h (_GL_HAS_BUILTIN_UNREACHABLE, unreachable): New
macros.
(abort): Declare if needed for unreachable.
* m4/stddef_h.m4 (gl_STDDEF_H): Test for unreachable.
* tests/test-stddef.c (test_unreachable_optimization,
test_unreachable_noreturn): New functions, based on tests/test-verify.c.
* doc/posix-headers/stddef.texi: Mention unreachable.
Diffstat (limited to 'm4/stddef_h.m4')
-rw-r--r-- | m4/stddef_h.m4 | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 index a2322ebb7e..aa012219fc 100644 --- a/m4/stddef_h.m4 +++ b/m4/stddef_h.m4 @@ -1,4 +1,4 @@ -# stddef_h.m4 serial 13 +# stddef_h.m4 serial 14 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -68,6 +68,21 @@ AC_DEFUN_ONCE([gl_STDDEF_H], GL_GENERATE_STDDEF_H=true fi + AC_CACHE_CHECK([for unreachable], + [gl_cv_func_unreachable], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <stddef.h> + ]], + [[unreachable (); + ]])], + [gl_cv_func_unreachable=yes], + [gl_cv_func_unreachable=no]) + ]) + if test $gl_cv_func_unreachable = no; then + GL_GENERATE_STDDEF_H=true + fi + if $GL_GENERATE_STDDEF_H; then gl_NEXT_HEADERS([stddef.h]) fi |