Skip to content

Commit 4f00632

Browse files
[libc] fix -Wmissing-attributes in setjmp
Fixes: llvm-project/libc/src/setjmp/x86_64/setjmp.cpp:21:25: error: ‘int __llvm_libc_19_0_0_git::setjmp(__jmp_buf*)’ specifies less restrictive attribute than its target ‘int __llvm_libc_19_0_0_git::__setjmp_impl__(__jmp_buf*)’: ‘nothrow’ [-Werror=missing-attributes] 21 | LLVM_LIBC_FUNCTION(int, setjmp, (__jmp_buf * buf)) { | ^~~~~~ observed in the GCC build by manually expanding LLVM_LIBC_FUNCTION to add `gnu::nothrow` to the alias. We probably need to revisit adding nothrow throughout our declarations, so there is probably a better way to clean this up in the future. Link: llvm#88054
1 parent 66f968c commit 4f00632

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

libc/src/setjmp/setjmp_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
namespace LIBC_NAMESPACE_DECL {
1818

19+
[[gnu::nothrow]]
1920
int setjmp(jmp_buf buf);
2021

2122
} // namespace LIBC_NAMESPACE_DECL

libc/src/setjmp/x86_64/setjmp.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@
1717

1818
namespace LIBC_NAMESPACE_DECL {
1919

20-
[[gnu::naked]]
21-
LLVM_LIBC_FUNCTION(int, setjmp, (__jmp_buf * buf)) {
20+
LLVM_LIBC_FUNCTION_ATTR decltype(LIBC_NAMESPACE::setjmp) __setjmp_impl__ __asm__("setjmp");
21+
22+
decltype(LIBC_NAMESPACE::setjmp) setjmp [[gnu::alias("setjmp"), gnu::nothrow]];
23+
24+
[[gnu::naked, gnu::nothrow]]
25+
int __setjmp_impl__ (__jmp_buf *buf) {
26+
2227
asm(R"(
2328
mov %%rbx, %c[rbx](%%rdi)
2429
mov %%rbp, %c[rbp](%%rdi)

0 commit comments

Comments
 (0)