diff options
author | Bruno Haible <bruno@clisp.org> | 2017-08-17 01:59:11 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2017-08-17 02:00:04 +0200 |
commit | daba2833be01f39982742b9bcdbbd1319be157aa (patch) | |
tree | 98952978adac34e567be7b8ec1eaf227f20f286f /m4/stdnoreturn.m4 | |
parent | b1efc4ac97cef0789dd85999fbb251ba13c07493 (diff) | |
download | gnulib-daba2833be01f39982742b9bcdbbd1319be157aa.tar.gz |
stdnoreturn: Fix test compilation failure on Cygwin.
* m4/stdnoreturn.m4 (gl_STDNORETURN_H): On Cygwin, use gnulib's
<stdnoreturn.h> replacement.
* lib/stdnoreturn.in.h (noreturn): Treat Cygwin like MSVC.
* doc/posix-headers/stdnoreturn.texi: Mention the Cygwin problem.
Diffstat (limited to 'm4/stdnoreturn.m4')
-rw-r--r-- | m4/stdnoreturn.m4 | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/m4/stdnoreturn.m4 b/m4/stdnoreturn.m4 index 9d70b3716b..ea4d73530b 100644 --- a/m4/stdnoreturn.m4 +++ b/m4/stdnoreturn.m4 @@ -9,33 +9,43 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_STDNORETURN_H], [ - AC_CACHE_CHECK([for working stdnoreturn.h], - [gl_cv_header_working_stdnoreturn_h], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include <stdlib.h> - #include <stdnoreturn.h> - /* Do not check for 'noreturn' after the return type. - C11 allows it, but it's rarely done that way - and circa-2012 bleeding-edge GCC rejects it when given - -Werror=old-style-declaration. */ - noreturn void foo1 (void) { exit (0); } - _Noreturn void foo2 (void) { exit (0); } - int testit (int argc, char **argv) { - if (argc & 1) - return 0; - (argv[0][0] ? foo1 : foo2) (); - } - ]])], - [gl_cv_header_working_stdnoreturn_h=yes], - [gl_cv_header_working_stdnoreturn_h=no])]) - - if test $gl_cv_header_working_stdnoreturn_h = yes; then - STDNORETURN_H='' - else - STDNORETURN_H='stdnoreturn.h' - fi - + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + cygwin*) + dnl Regardless whether a working <stdnoreturn.h> exists or not, + dnl we need our own <stdnoreturn.h>, because of the definition + dnl of _Noreturn done by gnulib-common.m4. + STDNORETURN_H='stdnoreturn.h' + ;; + *) + AC_CACHE_CHECK([for working stdnoreturn.h], + [gl_cv_header_working_stdnoreturn_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <stdlib.h> + #include <stdnoreturn.h> + /* Do not check for 'noreturn' after the return type. + C11 allows it, but it's rarely done that way + and circa-2012 bleeding-edge GCC rejects it when given + -Werror=old-style-declaration. */ + noreturn void foo1 (void) { exit (0); } + _Noreturn void foo2 (void) { exit (0); } + int testit (int argc, char **argv) + { + if (argc & 1) + return 0; + (argv[0][0] ? foo1 : foo2) (); + } + ]])], + [gl_cv_header_working_stdnoreturn_h=yes], + [gl_cv_header_working_stdnoreturn_h=no])]) + if test $gl_cv_header_working_stdnoreturn_h = yes; then + STDNORETURN_H='' + else + STDNORETURN_H='stdnoreturn.h' + fi + ;; + esac AC_SUBST([STDNORETURN_H]) AM_CONDITIONAL([GL_GENERATE_STDNORETURN_H], [test -n "$STDNORETURN_H"]) ]) |