X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fstdnoreturn.m4;h=5023613ec4d9597399987ab2cc3c8f976e23aaa4;hb=da8054d48dc22e1c051db54049e005d51a006e69;hp=1a44069363d1f91bc7afddbb5d437fc129db7a95;hpb=a64f669549a2ed455e99e313d6207a3711e5e5bd;p=gnulib.git diff --git a/m4/stdnoreturn.m4 b/m4/stdnoreturn.m4 index 1a4406936..5023613ec 100644 --- a/m4/stdnoreturn.m4 +++ b/m4/stdnoreturn.m4 @@ -1,22 +1,41 @@ -# Check for stdnoreturn.h. +# Check for stdnoreturn.h that conforms to C11. -dnl Copyright 2011 Free Software Foundation, Inc. +dnl Copyright 2012-2013 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +# Prepare for substituting if it is not supported. + AC_DEFUN([gl_STDNORETURN_H], [ - dnl Assume that a system-supplied stdnoreturn.h works if it exists. - AC_CHECK_HEADERS_ONCE([stdnoreturn.h]) + AC_CACHE_CHECK([for working stdnoreturn.h], + [gl_cv_header_working_stdnoreturn_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + /* 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 "$ac_cv_header_stdnoreturn_h" = yes; then + if test $gl_cv_header_working_stdnoreturn_h = yes; then STDNORETURN_H='' else STDNORETURN_H='stdnoreturn.h' fi - AC_SUBST([STDNORETURN_H]) - AM_CONDITIONAL([GL_GENERATE_STDNORETURN_H], - [test $ac_cv_header_stdnoreturn_h != yes]) + AC_SUBST([STDNORETURN_H]) + AM_CONDITIONAL([GL_GENERATE_STDNORETURN_H], [test -n "$STDNORETURN_H"]) ])