This implements a replacement for C11's <stdnoreturn.h>.
* doc/gnulib.texi (Header File Substitutes): Add stdnoreturn.
* doc/posix-headers/stdnoreturn.texi, lib/stdnoreturn.in.h:
* m4/stdnoreturn.m4, modules/stdnoreturn, modules/stdnoreturn-tests:
* tests/test-stdnoreturn.c: New files.
+2012-02-24 Paul Eggert <eggert@cs.ucla.edu>
+
+ stdnoreturn: new module
+ This implements a replacement for C11's <stdnoreturn.h>.
+ * doc/gnulib.texi (Header File Substitutes): Add stdnoreturn.
+ * doc/posix-headers/stdnoreturn.texi, lib/stdnoreturn.in.h:
+ * m4/stdnoreturn.m4, modules/stdnoreturn, modules/stdnoreturn-tests:
+ * tests/test-stdnoreturn.c: New files.
+
2012-02-24 Stanislav Brabec <sbrabec@suse.cz> (tiny change)
regex: fix false multibyte matches in some regular expressions
* stdint.h::
* stdio.h::
* stdlib.h::
+* stdnoreturn.h::
* string.h::
* strings.h::
* stropts.h::
@include posix-headers/stdint.texi
@include posix-headers/stdio.texi
@include posix-headers/stdlib.texi
+@include posix-headers/stdnoreturn.texi
@include posix-headers/string.texi
@include posix-headers/strings.texi
@include posix-headers/stropts.texi
--- /dev/null
+@node stdnoreturn.h
+@section @file{stdnoreturn.h}
+
+POSIX specification:@* Not in POSIX yet, but we expect it will be.
+ISO C11 (latest free draft
+@url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf})
+sections 7.23.
+
+Gnulib module: stdnoreturn
+
+Portability problems fixed by Gnulib:
+@itemize
+@item
+This header file is missing on most circa-2012 platforms.
+@end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@item
+@code{<stdnoreturn.h>} should be #included before @samp{_Noreturn} is used.
+@item
+You cannot assume that @code{_Noreturn} is a reserved word;
+it might be a macro.
+@end itemize
--- /dev/null
+/* A substitute for ISO C11 <stdnoreturn.h>.
+
+ Copyright 2012 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#ifndef noreturn
+
+/* ISO C11 <stdnoreturn.h> for platforms that lack it.
+
+ References:
+ ISO C11 (latest free draft
+ <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
+ section 7.23 */
+
+/* The definition of _Noreturn is copied here. */
+
+#define noreturn _Noreturn
+
+/* Did he ever return?
+ No he never returned
+ And his fate is still unlearn'd ...
+ -- Steiner J, Hawes BL. M.T.A. (1949) */
+
+#endif /* noreturn */
--- /dev/null
+# Check for stdnoreturn.h that conforms to C11.
+
+dnl Copyright 2012 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>
+ void noreturn foo1 (void) { exit (0); }
+ void _Noreturn foo2 (void) { exit (0); }
+ noreturn void foo3 (void) { exit (0); }
+ _Noreturn void foo4 (void) { exit (0); }
+ int main (int argc, char **argv) {
+ if (argc & 1)
+ return 0;
+ ((argv[0][0]
+ ? (argv[0][1] ? foo1 : foo2)
+ : (argv[0][1] ? foo3 : foo4))
+ ());
+ }
+ ]])],
+ [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"])
+])
--- /dev/null
+Description:
+A <stdnoreturn.h> that nearly conforms to ISO C11.
+
+Files:
+lib/stdnoreturn.in.h
+m4/stdnoreturn.m4
+
+Depends-on:
+snippet/_Noreturn
+
+configure.ac:
+gl_STDNORETURN_H
+
+Makefile.am:
+BUILT_SOURCES += $(STDNORETURN_H)
+
+# We need the following in order to create <stdnoreturn.h> when the system
+# doesn't have one that works.
+if GL_GENERATE_STDNORETURN_H
+stdnoreturn.h: stdnoreturn.in.h $(top_builddir)/config.status $(_NORETURN_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e '/definition of _Noreturn/r $(_NORETURN_H)' \
+ < $(srcdir)/stdnoreturn.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+stdnoreturn.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += stdnoreturn.h stdnoreturn.h-t
+
+Include:
+<stdnoreturn.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Paul Eggert
--- /dev/null
+Files:
+tests/test-stdnoreturn.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-stdnoreturn
+check_PROGRAMS += test-stdnoreturn
--- /dev/null
+/* Test of <stdnoreturn.h>.
+ Copyright 2012 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#include <config.h>
+
+#include <stdnoreturn.h>
+
+#include <stdlib.h>
+
+noreturn void
+does_not_return (void)
+{
+ exit (0);
+}
+
+int
+main (void)
+{
+ does_not_return ();
+}