Building a gnulib testdir for module 'obstack' with clang, I get this warning:

../../gllib/obstack.c:351:31: warning: incompatible pointer types initializing 
'void (*)(void) __attribute__((noreturn))' with an expression of type 'void 
(void)' [-Wincompatible-pointer-types]
__attribute_noreturn__ void (*obstack_alloc_failed_handler) (void)
                              ^
1 warning generated.


The reason is that _Noreturn and __attribute__((noreturn)) are different:
_Noreturn does not apply to function pointers, but __attribute__((noreturn))
does. See lib/noreturn.h lines 67..69.

This patch fixes it.


2020-10-18  Bruno Haible  <br...@clisp.org>

        obstack: Fix a clang warning.
        * lib/obstack.c (print_and_abort): Mark as __attribute_noreturn__.

diff --git a/lib/obstack.c b/lib/obstack.c
index 6e82da0..e6475a2 100644
--- a/lib/obstack.c
+++ b/lib/obstack.c
@@ -326,7 +326,7 @@ int obstack_exit_failure = EXIT_FAILURE;
 #   include <libio/iolibio.h>
 #  endif
 
-static _Noreturn void
+static __attribute_noreturn__ void
 print_and_abort (void)
 {
   /* Don't change any of these strings.  Yes, it would be possible to add


Reply via email to