Skip to content

Commit 519fcc5

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)) { | ^~~~~~ Marking functions as 'naked' implies 'nothrow', so the function declaration should be marked nothrow. Only do this conditionally for GCC for now, otherwise clang with diagnose -Wmissing-exception-spec on the __ ## name ## _impl__ alias. We probably need to revisit adding nothrow throughout our definitions, so there is probably a better way to clean this up in the future. Link: #88054
1 parent 66f968c commit 519fcc5

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

libc/src/setjmp/setjmp_impl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
// public header setjmp.h which is also included. here.
1414
#include "hdr/types/jmp_buf.h"
1515
#include "src/__support/macros/config.h"
16+
#include "src/__support/macros/properties/compiler.h"
1617

1718
namespace LIBC_NAMESPACE_DECL {
1819

20+
#ifdef LIBC_COMPILER_IS_GCC
21+
[[gnu::nothrow]]
22+
#endif
1923
int setjmp(jmp_buf buf);
2024

2125
} // namespace LIBC_NAMESPACE_DECL

libc/src/setjmp/x86_64/setjmp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
namespace LIBC_NAMESPACE_DECL {
1919

2020
[[gnu::naked]]
21-
LLVM_LIBC_FUNCTION(int, setjmp, (__jmp_buf * buf)) {
21+
LLVM_LIBC_FUNCTION(int, setjmp, (jmp_buf buf)) {
2222
asm(R"(
2323
mov %%rbx, %c[rbx](%%rdi)
2424
mov %%rbp, %c[rbp](%%rdi)

0 commit comments

Comments
 (0)