]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix compile error due to [[noreturn]] with clang
authorAndrew Oates <andrew@andrewoates.com>
Fri, 25 Oct 2024 23:35:34 +0000 (19:35 -0400)
committerTom Tromey <tromey@adacore.com>
Fri, 1 Nov 2024 17:13:54 +0000 (11:13 -0600)
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 <tom@tromey.com>
gdb/remote-sim.c

index 67d3f4c8b1c137ad0654fe6cda9eb5424f732dae..8e2a54fe653814013f510156442c416fd64521e6 100644 (file)
@@ -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: