view m4/stdnoreturn.m4 @ 17364:7524d97ae56f

stdalign: port to stricter ISO C11 ISO C11 says that _Alignof's operand must be a parenthesized type. Problem reported by Eli Zaretskii in <http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00960.html>. * doc/posix-headers/stdalign.texi (stdalign.h): Document this. * m4/stdalign.m4 (gl_STDALIGN_H): Don't use _Alignof (expr).
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 29 Mar 2013 19:47:13 -0700
parents e542fd46ad6f
children 344018b6e5d7
line wrap: on
line source

# Check for stdnoreturn.h that conforms to C11.

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 <stdnoreturn.h> if it is not supported.

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_SUBST([STDNORETURN_H])
  AM_CONDITIONAL([GL_GENERATE_STDNORETURN_H], [test -n "$STDNORETURN_H"])
])