]> Savannah Git Hosting - gnulib.git/commitdiff
obstack: pacify GCC 6 with -Wnull-dereference
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 15 Jul 2016 08:35:22 +0000 (10:35 +0200)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 15 Jul 2016 10:15:37 +0000 (12:15 +0200)
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.

ChangeLog
lib/obstack.c
lib/obstack.h

index 848da1b4835f64ac9dcb2bc171f257d4f23efdb8..2414e8e7d3f8abea692ee66e67811457a28204c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 5ce256a6db945e197030509ca570fe7c7e6a6f0a..f0da2f7361bd77d8c15a1a9492658dd9a52c4193 100644 (file)
@@ -348,6 +348,7 @@ print_and_abort (void)
    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 */
index 67623ad22c8b8439260f2b7f78ab45b40ad67e72..e81c907a68de24e3742f90c389d47122f3b338ef 100644 (file)
 # 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 @@ extern _OBSTACK_SIZE_T _obstack_memory_used (struct obstack *)
    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;