# HG changeset patch # User Paul Eggert # Date 1345765205 25200 # Node ID aa2fec6b7d372768bc84ef0767d0df077ed30e1c # Parent 4d1be35449073b010e144ffdd89a6678e69ec251 stdnoreturn: port to newer GCCs * m4/stdnoreturn.m4 (gl_STDNORETURN_H): Avoid problems with bleeding-edge GCC that complains about 'int _Noreturn foo (void);'. Problem reported by Jim Meyering in . Also, rename the 'test' function to a void a clash with the already-supplied 'main' function; this fixes a bug that incorrectly rejected GCC 4.7.1's . * doc/posix-headers/stdnoreturn.texi (stdnoreturn.h): Document GCC problem. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2012-08-23 Paul Eggert + + stdnoreturn: port to newer GCCs + * m4/stdnoreturn.m4 (gl_STDNORETURN_H): Avoid problems with + bleeding-edge GCC that complains about 'int _Noreturn foo (void);'. + Problem reported by Jim Meyering in + . + Also, rename the 'test' function to a void a clash with the + already-supplied 'main' function; this fixes a bug that incorrectly + rejected GCC 4.7.1's . + * doc/posix-headers/stdnoreturn.texi (stdnoreturn.h): + Document GCC problem. + 2012-08-22 Reuben Thomas pipe-filter: fix comment typo diff --git a/doc/posix-headers/stdnoreturn.texi b/doc/posix-headers/stdnoreturn.texi --- a/doc/posix-headers/stdnoreturn.texi +++ b/doc/posix-headers/stdnoreturn.texi @@ -28,5 +28,9 @@ compiler is not informed whether @code{noreturn} functions do not return, so it may generate incorrect warnings at compile-time, or code that is slightly less optimized. This problem does not occur with -@code{_Noreturn}. +@item +Circa 2012 bleeding-edge GCC with @code{-Werror=old-style-declaration} +requires @code{_Noreturn} or @code{noreturn} before the returned type +in a declaration, and therefore rejects valid but unusually-worded +declarations such as @code{void _Noreturn foo (void);}. @end itemize diff --git a/m4/stdnoreturn.m4 b/m4/stdnoreturn.m4 --- a/m4/stdnoreturn.m4 +++ b/m4/stdnoreturn.m4 @@ -15,17 +15,16 @@ [AC_LANG_PROGRAM( [[#include #include - 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) { + /* 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] - ? (argv[0][1] ? foo1 : foo2) - : (argv[0][1] ? foo3 : foo4)) - ()); + (argv[0][0] ? foo1 : foo2) (); } ]])], [gl_cv_header_working_stdnoreturn_h=yes],