[libc-commits] [libc] [libc] fix -Wgcc-compat (PR #120303)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Tue Dec 17 13:06:40 PST 2024
https://github.com/nickdesaulniers updated https://github.com/llvm/llvm-project/pull/120303
>From 0870e278e84e1271adbac096c740af96962e3fb7 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Tue, 17 Dec 2024 13:01:18 -0800
Subject: [PATCH 1/2] [libc] fix -Wgcc-compat
I don't quite recall why I added those in the first place. These tests build
without diagnostics for both clang and GCC with this fix.
Fixes: #114653
---
libc/test/include/stdbit_stub.h | 40 ++++++++++++++++-----------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/libc/test/include/stdbit_stub.h b/libc/test/include/stdbit_stub.h
index 65b1ca3b2c2976..7cdb3948855499 100644
--- a/libc/test/include/stdbit_stub.h
+++ b/libc/test/include/stdbit_stub.h
@@ -17,19 +17,19 @@
#include <stdbool.h> // bool in C
#define STDBIT_STUB_FUNCTION(FUNC_NAME, LEADING_VAL) \
- unsigned FUNC_NAME##_uc(unsigned char x) __NOEXCEPT { \
+ unsigned FUNC_NAME##_uc(unsigned char x) { \
return LEADING_VAL##AU; \
} \
- unsigned FUNC_NAME##_us(unsigned short x) __NOEXCEPT { \
+ unsigned FUNC_NAME##_us(unsigned short x) { \
return LEADING_VAL##BU; \
} \
- unsigned FUNC_NAME##_ui(unsigned int x) __NOEXCEPT { \
+ unsigned FUNC_NAME##_ui(unsigned int x) { \
return LEADING_VAL##CU; \
} \
- unsigned FUNC_NAME##_ul(unsigned long x) __NOEXCEPT { \
+ unsigned FUNC_NAME##_ul(unsigned long x) { \
return LEADING_VAL##DU; \
} \
- unsigned FUNC_NAME##_ull(unsigned long long x) __NOEXCEPT { \
+ unsigned FUNC_NAME##_ull(unsigned long long x) { \
return LEADING_VAL##EU; \
}
@@ -46,27 +46,27 @@ STDBIT_STUB_FUNCTION(stdc_first_trailing_one, 0x1)
STDBIT_STUB_FUNCTION(stdc_count_zeros, 0x2)
STDBIT_STUB_FUNCTION(stdc_count_ones, 0x3)
-bool stdc_has_single_bit_uc(unsigned char x) __NOEXCEPT { return false; }
-bool stdc_has_single_bit_us(unsigned short x) __NOEXCEPT { return false; }
-bool stdc_has_single_bit_ui(unsigned x) __NOEXCEPT { return false; }
-bool stdc_has_single_bit_ul(unsigned long x) __NOEXCEPT { return false; }
-bool stdc_has_single_bit_ull(unsigned long long x) __NOEXCEPT { return false; }
+bool stdc_has_single_bit_uc(unsigned char x) { return false; }
+bool stdc_has_single_bit_us(unsigned short x) { return false; }
+bool stdc_has_single_bit_ui(unsigned x) { return false; }
+bool stdc_has_single_bit_ul(unsigned long x) { return false; }
+bool stdc_has_single_bit_ull(unsigned long long x) { return false; }
STDBIT_STUB_FUNCTION(stdc_bit_width, 0x4)
-unsigned char stdc_bit_floor_uc(unsigned char x) __NOEXCEPT { return 0x5AU; }
-unsigned short stdc_bit_floor_us(unsigned short x) __NOEXCEPT { return 0x5BU; }
-unsigned stdc_bit_floor_ui(unsigned x) __NOEXCEPT { return 0x5CU; }
-unsigned long stdc_bit_floor_ul(unsigned long x) __NOEXCEPT { return 0x5DUL; }
-unsigned long long stdc_bit_floor_ull(unsigned long long x) __NOEXCEPT {
+unsigned char stdc_bit_floor_uc(unsigned char x) { return 0x5AU; }
+unsigned short stdc_bit_floor_us(unsigned short x) { return 0x5BU; }
+unsigned stdc_bit_floor_ui(unsigned x) { return 0x5CU; }
+unsigned long stdc_bit_floor_ul(unsigned long x) { return 0x5DUL; }
+unsigned long long stdc_bit_floor_ull(unsigned long long x) {
return 0x5EULL;
}
-unsigned char stdc_bit_ceil_uc(unsigned char x) __NOEXCEPT { return 0x6AU; }
-unsigned short stdc_bit_ceil_us(unsigned short x) __NOEXCEPT { return 0x6BU; }
-unsigned stdc_bit_ceil_ui(unsigned x) __NOEXCEPT { return 0x6CU; }
-unsigned long stdc_bit_ceil_ul(unsigned long x) __NOEXCEPT { return 0x6DUL; }
-unsigned long long stdc_bit_ceil_ull(unsigned long long x) __NOEXCEPT {
+unsigned char stdc_bit_ceil_uc(unsigned char x) { return 0x6AU; }
+unsigned short stdc_bit_ceil_us(unsigned short x) { return 0x6BU; }
+unsigned stdc_bit_ceil_ui(unsigned x) { return 0x6CU; }
+unsigned long stdc_bit_ceil_ul(unsigned long x) { return 0x6DUL; }
+unsigned long long stdc_bit_ceil_ull(unsigned long long x) {
return 0x6EULL;
}
>From ca73501a99e5be136329e3d1db89247facaa3e45 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Tue, 17 Dec 2024 13:06:27 -0800
Subject: [PATCH 2/2] appease formatter
---
libc/test/include/stdbit_stub.h | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/libc/test/include/stdbit_stub.h b/libc/test/include/stdbit_stub.h
index 7cdb3948855499..8a8e30e889d6d7 100644
--- a/libc/test/include/stdbit_stub.h
+++ b/libc/test/include/stdbit_stub.h
@@ -17,21 +17,11 @@
#include <stdbool.h> // bool in C
#define STDBIT_STUB_FUNCTION(FUNC_NAME, LEADING_VAL) \
- unsigned FUNC_NAME##_uc(unsigned char x) { \
- return LEADING_VAL##AU; \
- } \
- unsigned FUNC_NAME##_us(unsigned short x) { \
- return LEADING_VAL##BU; \
- } \
- unsigned FUNC_NAME##_ui(unsigned int x) { \
- return LEADING_VAL##CU; \
- } \
- unsigned FUNC_NAME##_ul(unsigned long x) { \
- return LEADING_VAL##DU; \
- } \
- unsigned FUNC_NAME##_ull(unsigned long long x) { \
- return LEADING_VAL##EU; \
- }
+ unsigned FUNC_NAME##_uc(unsigned char x) { return LEADING_VAL##AU; } \
+ unsigned FUNC_NAME##_us(unsigned short x) { return LEADING_VAL##BU; } \
+ unsigned FUNC_NAME##_ui(unsigned int x) { return LEADING_VAL##CU; } \
+ unsigned FUNC_NAME##_ul(unsigned long x) { return LEADING_VAL##DU; } \
+ unsigned FUNC_NAME##_ull(unsigned long long x) { return LEADING_VAL##EU; }
__BEGIN_C_DECLS
@@ -58,16 +48,12 @@ unsigned char stdc_bit_floor_uc(unsigned char x) { return 0x5AU; }
unsigned short stdc_bit_floor_us(unsigned short x) { return 0x5BU; }
unsigned stdc_bit_floor_ui(unsigned x) { return 0x5CU; }
unsigned long stdc_bit_floor_ul(unsigned long x) { return 0x5DUL; }
-unsigned long long stdc_bit_floor_ull(unsigned long long x) {
- return 0x5EULL;
-}
+unsigned long long stdc_bit_floor_ull(unsigned long long x) { return 0x5EULL; }
unsigned char stdc_bit_ceil_uc(unsigned char x) { return 0x6AU; }
unsigned short stdc_bit_ceil_us(unsigned short x) { return 0x6BU; }
unsigned stdc_bit_ceil_ui(unsigned x) { return 0x6CU; }
unsigned long stdc_bit_ceil_ul(unsigned long x) { return 0x6DUL; }
-unsigned long long stdc_bit_ceil_ull(unsigned long long x) {
- return 0x6EULL;
-}
+unsigned long long stdc_bit_ceil_ull(unsigned long long x) { return 0x6EULL; }
__END_C_DECLS
More information about the libc-commits
mailing list