1275970Scy# Check for stdnoreturn.h that conforms to C11.
2275970Scy
3285169Scydnl Copyright 2012-2015 Free Software Foundation, Inc.
4275970Scydnl This file is free software; the Free Software Foundation
5275970Scydnl gives unlimited permission to copy and/or distribute it,
6275970Scydnl with or without modifications, as long as this notice is preserved.
7275970Scy
8275970Scy# Prepare for substituting <stdnoreturn.h> if it is not supported.
9275970Scy
10275970ScyAC_DEFUN([gl_STDNORETURN_H],
11275970Scy[
12275970Scy  AC_CACHE_CHECK([for working stdnoreturn.h],
13275970Scy    [gl_cv_header_working_stdnoreturn_h],
14275970Scy    [AC_COMPILE_IFELSE(
15275970Scy       [AC_LANG_PROGRAM(
16275970Scy          [[#include <stdlib.h>
17275970Scy            #include <stdnoreturn.h>
18275970Scy            /* Do not check for 'noreturn' after the return type.
19275970Scy               C11 allows it, but it's rarely done that way
20275970Scy               and circa-2012 bleeding-edge GCC rejects it when given
21275970Scy               -Werror=old-style-declaration.  */
22275970Scy            noreturn void foo1 (void) { exit (0); }
23275970Scy            _Noreturn void foo2 (void) { exit (0); }
24275970Scy            int testit (int argc, char **argv) {
25275970Scy              if (argc & 1)
26275970Scy                return 0;
27275970Scy              (argv[0][0] ? foo1 : foo2) ();
28275970Scy            }
29275970Scy          ]])],
30275970Scy       [gl_cv_header_working_stdnoreturn_h=yes],
31275970Scy       [gl_cv_header_working_stdnoreturn_h=no])])
32275970Scy
33275970Scy  if test $gl_cv_header_working_stdnoreturn_h = yes; then
34275970Scy    STDNORETURN_H=''
35275970Scy  else
36275970Scy    STDNORETURN_H='stdnoreturn.h'
37275970Scy  fi
38275970Scy
39275970Scy  AC_SUBST([STDNORETURN_H])
40275970Scy  AM_CONDITIONAL([GL_GENERATE_STDNORETURN_H], [test -n "$STDNORETURN_H"])
41275970Scy])
42