diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2012-08-23 16:40:05 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-08-23 16:42:35 -0700 |
commit | 8f25604017b00aec5a7b2a37fc96a55f2c948ec9 (patch) | |
tree | d19611ff55d1b0836ffe2981e2525640407e8a10 | |
parent | f1394395d0fb27521f7b1610aca2b01a7ee64825 (diff) | |
download | gnulib-8f25604017b00aec5a7b2a37fc96a55f2c948ec9.tar.gz |
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
<http://lists.gnu.org/archive/html/bug-gnulib/2012-08/msg00121.html>.
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 <stdnoreturn.h>.
* doc/posix-headers/stdnoreturn.texi (stdnoreturn.h):
Document GCC problem.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | doc/posix-headers/stdnoreturn.texi | 6 | ||||
-rw-r--r-- | m4/stdnoreturn.m4 | 17 |
3 files changed, 26 insertions, 10 deletions
@@ -1,3 +1,16 @@ +2012-08-23 Paul Eggert <eggert@cs.ucla.edu> + + 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 + <http://lists.gnu.org/archive/html/bug-gnulib/2012-08/msg00121.html>. + 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 <stdnoreturn.h>. + * doc/posix-headers/stdnoreturn.texi (stdnoreturn.h): + Document GCC problem. + 2012-08-22 Reuben Thomas <rrt@sc3d.org> pipe-filter: fix comment typo diff --git a/doc/posix-headers/stdnoreturn.texi b/doc/posix-headers/stdnoreturn.texi index a7dab0fc44..9b500cc93e 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 6e10b120ae..84027cbd17 100644 --- a/m4/stdnoreturn.m4 +++ b/m4/stdnoreturn.m4 @@ -15,17 +15,16 @@ AC_DEFUN([gl_STDNORETURN_H], [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) { + /* 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], |