From: Andrew Oates Date: Fri, 25 Oct 2024 23:35:34 +0000 (-0400) Subject: Fix compile error due to [[noreturn]] with clang X-Git-Tag: gdb-16-branchpoint~550 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=086a2beb152c95ac43ac6b73859eb9e9081fc2df;p=thirdparty%2Fbinutils-gdb.git Fix compile error due to [[noreturn]] with clang Since commit d9deb60b2e9e94b532f43a7d3ddddf5ddf6dbdd3, I get the following compiler error when building binutils (cross-compiling) on macos: CXX remote-sim.o ../../gdb/remote-sim.c:334:28: error: assigning to 'void (*)(host_callback *, const char *, ...) __attribute__((noreturn))' (aka 'void (*)(host_callback_struct *, const char *, ...) __attribute__((noreturn))') from incompatible type 'void (host_callback *, const char *, ...)' (aka 'void (host_callback_struct *, const char *, ...)') gdb_callback.error = gdb_os_error; ^~~~~~~~~~~~ 1 error generated. This appears to be due to the mismatch between ATTRIBUTE_NORETURN and [[noreturn]] on gdb_os_error. Reverting the change for gdb_os_error resolves the issue. Removing ATTTRIBUTE_NORETURN on the declaration of host_callback::error also works, but deprives the compiler of data. Tested by compiling on macos both with the system clang, as well as with GCC 14. With clang, remote-sim.c does not compile (per above) without this patch. With GCC, it compiles with and without the patch (it doesn't link, but AFAICT that is unrelated). The clang bug is reported upstream at https://github.com/llvm/llvm-project/issues/113511 Approved-By: Tom Tromey --- diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 67d3f4c8b1c..8e2a54fe653 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -69,7 +69,8 @@ static void gdb_os_vprintf_filtered (host_callback *, const char *, va_list); static void gdb_os_evprintf_filtered (host_callback *, const char *, va_list); -[[noreturn]] static void gdb_os_error (host_callback *, const char *, ...); +static void gdb_os_error (host_callback *, const char *, ...) + ATTRIBUTE_NORETURN; /* Naming convention: