Mercurial > hg > octave-kai > gnulib-hg
changeset 17059:aa2fec6b7d37
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.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 23 Aug 2012 16:40:05 -0700 |
parents | 4d1be3544907 |
children | 4c9ad7a11699 |
files | ChangeLog doc/posix-headers/stdnoreturn.texi m4/stdnoreturn.m4 |
diffstat | 3 files changed, 26 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -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
--- 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
--- a/m4/stdnoreturn.m4 +++ b/m4/stdnoreturn.m4 @@ -15,17 +15,16 @@ [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],