Mercurial > gnulib
changeset 18344:e78bf6526393
obstack: pacify GCC 6 with -Wnull-dereference
Problem reported by Assaf Gordon in:
http://lists.gnu.org/archive/html/bug-gnulib/2016-07/msg00028.html
* lib/obstack.c, lib/obstack.h (obstack_alloc_failed_handler):
Declare with __attribute_noreturn__.
* lib/obstack.h (__attribute_noreturn__): New macro.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 15 Jul 2016 10:35:22 +0200 |
parents | 3587dcd977e4 |
children | 444cca940b8f |
files | ChangeLog lib/obstack.c lib/obstack.h |
diffstat | 3 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Jul 14 08:36:45 2016 -0700 +++ b/ChangeLog Fri Jul 15 10:35:22 2016 +0200 @@ -1,3 +1,12 @@ +2016-07-15 Paul Eggert <eggert@cs.ucla.edu> + + obstack: pacify GCC 6 with -Wnull-dereference + Problem reported by Assaf Gordon in: + http://lists.gnu.org/archive/html/bug-gnulib/2016-07/msg00028.html + * lib/obstack.c, lib/obstack.h (obstack_alloc_failed_handler): + Declare with __attribute_noreturn__. + * lib/obstack.h (__attribute_noreturn__): New macro. + 2016-07-13 Eric Blake <eblake@redhat.com> doc: mention glibc, OS X, Cygwin [S]SIZE_MAX buglet
--- a/lib/obstack.c Thu Jul 14 08:36:45 2016 -0700 +++ b/lib/obstack.c Fri Jul 15 10:35:22 2016 +0200 @@ -348,6 +348,7 @@ abort gracefully or use longjump - but shouldn't return. This variable by default points to the internal function 'print_and_abort'. */ -void (*obstack_alloc_failed_handler) (void) = print_and_abort; +__attribute_noreturn__ void (*obstack_alloc_failed_handler) (void) + = print_and_abort; # endif /* !_OBSTACK_NO_ERROR_HANDLER */ #endif /* !_OBSTACK_ELIDE_CODE */
--- a/lib/obstack.h Thu Jul 14 08:36:45 2016 -0700 +++ b/lib/obstack.h Fri Jul 15 10:35:22 2016 +0200 @@ -145,6 +145,15 @@ # define __attribute_pure__ _GL_ATTRIBUTE_PURE #endif +/* Not the same as _Noreturn, since it also works with function pointers. */ +#ifndef __attribute_noreturn__ +# if 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C +# define __attribute_noreturn__ __attribute__ ((__noreturn__)) +# else +# define __attribute_noreturn__ +# endif +#endif + #ifdef __cplusplus extern "C" { #endif @@ -212,7 +221,7 @@ more memory. This can be set to a user defined function which should either abort gracefully or use longjump - but shouldn't return. The default action is to print a message and abort. */ -extern void (*obstack_alloc_failed_handler) (void); +extern __attribute_noreturn__ void (*obstack_alloc_failed_handler) (void); /* Exit value used when 'print_and_abort' is used. */ extern int obstack_exit_failure;