Debian Codegraph @

m4/stdnoreturn.m4

raw
1 # stdnoreturn.m4
2 # serial 1
3 dnl Copyright 2012-2025 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 # Check for stdnoreturn.h that conforms to C11.
10
11 # Prepare for substituting <stdnoreturn.h> if it is not supported.
12
13 AC_DEFUN([gl_STDNORETURN_H],
14 [
15 AC_REQUIRE([AC_CANONICAL_HOST])
16 case "$host_os" in
17 cygwin*)
18 dnl Regardless whether a working <stdnoreturn.h> exists or not,
19 dnl we need our own <stdnoreturn.h>, because of the definition
20 dnl of _Noreturn done by gnulib-common.m4.
21 GL_GENERATE_STDNORETURN_H=true
22 ;;
23 *)
24 AC_CACHE_CHECK([for working stdnoreturn.h],
25 [gl_cv_header_working_stdnoreturn_h],
26 [AC_COMPILE_IFELSE(
27 [AC_LANG_PROGRAM(
28 [[#include <stdlib.h>
29 #include <stdnoreturn.h>
30 #if defined _WIN32 && !defined __CYGWIN__
31 # include <process.h>
32 #endif
33 /* Do not check for 'noreturn' after the return type.
34 C11 allows it, but it's rarely done that way
35 and circa-2012 bleeding-edge GCC rejects it when given
36 -Werror=old-style-declaration. */
37 noreturn void foo1 (void) { exit (0); }
38 _Noreturn void foo2 (void) { exit (0); }
39 int testit (int argc, char **argv)
40 {
41 if (argc & 1)
42 return 0;
43 (argv[0][0] ? foo1 : foo2) ();
44 }
45 ]])],
46 [gl_cv_header_working_stdnoreturn_h=yes],
47 [gl_cv_header_working_stdnoreturn_h=no])])
48 if test $gl_cv_header_working_stdnoreturn_h = yes; then
49 GL_GENERATE_STDNORETURN_H=false
50 else
51 GL_GENERATE_STDNORETURN_H=true
52 fi
53 ;;
54 esac
55 ])