From 8f25604017b00aec5a7b2a37fc96a55f2c948ec9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 23 Aug 2012 16:40:05 -0700 Subject: [PATCH] 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. --- ChangeLog | 13 +++++++++++++ doc/posix-headers/stdnoreturn.texi | 6 +++++- m4/stdnoreturn.m4 | 17 ++++++++--------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16b454017..b46a8bd89 100644 --- 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 index a7dab0fc4..9b500cc93 100644 --- a/doc/posix-headers/stdnoreturn.texi +++ b/doc/posix-headers/stdnoreturn.texi @@ -28,5 +28,9 @@ directly. Although the resulting code operates correctly, the 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 index 6e10b120a..84027cbd1 100644 --- a/m4/stdnoreturn.m4 +++ b/m4/stdnoreturn.m4 @@ -15,17 +15,16 @@ AC_DEFUN([gl_STDNORETURN_H], [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], -- 2.11.0