[v2] Fix compile error due to [[noreturn]] with clang
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
Commit Message
From: Andrew Oates <andrew@andrewoates.com>
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
---
v2 reverts the change to gdb_os_error rather than changing the type of
the callback.
gdb/remote-sim.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
>>>>> andrew <andrew@andrewoates.com> writes:
> -[[noreturn]] static void gdb_os_error (host_callback *, const char *, ...);
> +static void gdb_os_error(host_callback *, const char *, ...)
> + ATTRIBUTE_NORETURN;
I fixed the little formatting error here (removed a space) and added my
approved-by. I'm going to push it in a second.
Tom
@@ -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: