stdnoreturn.m4 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Check for stdnoreturn.h that conforms to C11.
  2. dnl Copyright 2012-2016 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. # Prepare for substituting <stdnoreturn.h> if it is not supported.
  7. AC_DEFUN([gl_STDNORETURN_H],
  8. [
  9. AC_CACHE_CHECK([for working stdnoreturn.h],
  10. [gl_cv_header_working_stdnoreturn_h],
  11. [AC_COMPILE_IFELSE(
  12. [AC_LANG_PROGRAM(
  13. [[#include <stdlib.h>
  14. #include <stdnoreturn.h>
  15. /* Do not check for 'noreturn' after the return type.
  16. C11 allows it, but it's rarely done that way
  17. and circa-2012 bleeding-edge GCC rejects it when given
  18. -Werror=old-style-declaration. */
  19. noreturn void foo1 (void) { exit (0); }
  20. _Noreturn void foo2 (void) { exit (0); }
  21. int testit (int argc, char **argv) {
  22. if (argc & 1)
  23. return 0;
  24. (argv[0][0] ? foo1 : foo2) ();
  25. }
  26. ]])],
  27. [gl_cv_header_working_stdnoreturn_h=yes],
  28. [gl_cv_header_working_stdnoreturn_h=no])])
  29. if test $gl_cv_header_working_stdnoreturn_h = yes; then
  30. STDNORETURN_H=''
  31. else
  32. STDNORETURN_H='stdnoreturn.h'
  33. fi
  34. AC_SUBST([STDNORETURN_H])
  35. AM_CONDITIONAL([GL_GENERATE_STDNORETURN_H], [test -n "$STDNORETURN_H"])
  36. ])