[libc-commits] [libc] e617dc8 - [libc] Add -Wextra for libc tests (#133643)

via libc-commits libc-commits at lists.llvm.org
Tue Aug 12 04:27:17 PDT 2025


Author: Vinay Deshmukh
Date: 2025-08-12T12:27:13+01:00
New Revision: e617dc80bf9376ca948ee7af8304ea00b2263b51

URL: https://github.com/llvm/llvm-project/commit/e617dc80bf9376ca948ee7af8304ea00b2263b51
DIFF: https://github.com/llvm/llvm-project/commit/e617dc80bf9376ca948ee7af8304ea00b2263b51.diff

LOG: [libc] Add -Wextra for libc tests (#133643)

* Relates to: https://github.com/llvm/llvm-project/issues/119281

Added: 
    

Modified: 
    libc/cmake/modules/LLVMLibCTestRules.cmake
    libc/test/UnitTest/FPExceptMatcher.cpp
    libc/test/UnitTest/FPExceptMatcher.h
    libc/test/UnitTest/HermeticTestUtils.cpp
    libc/test/UnitTest/LibcDeathTestExecutors.cpp
    libc/test/UnitTest/LibcTest.h
    libc/test/include/stdbit_stub.h
    libc/test/integration/src/pthread/pthread_mutex_test.cpp
    libc/test/integration/src/spawn/posix_spawn_test.cpp
    libc/test/integration/src/spawn/posix_spawn_test_binary.cpp
    libc/test/integration/src/stdio/sprintf_size_test.cpp
    libc/test/integration/src/stdlib/getenv_test.cpp
    libc/test/integration/src/threads/cnd_test.cpp
    libc/test/integration/src/threads/mtx_test.cpp
    libc/test/integration/src/unistd/execv_test.cpp
    libc/test/integration/src/unistd/execve_test.cpp
    libc/test/integration/src/unistd/fork_test.cpp
    libc/test/integration/src/unistd/getcwd_test.cpp
    libc/test/integration/startup/linux/main_without_envp.cpp
    libc/test/integration/startup/linux/tls_test.cpp
    libc/test/src/__support/CPP/integer_sequence_test.cpp
    libc/test/src/__support/freelist_heap_test.cpp
    libc/test/src/math/exhaustive/hypotf16_test.cpp
    libc/test/src/stdlib/StrfromTest.h
    libc/test/src/string/memory_utils/op_tests.cpp
    libc/test/src/strings/bzero_test.cpp
    libc/utils/MPFRWrapper/MPFRUtils.h

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 30b1fd10a1774..44cc6a35df886 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -40,7 +40,7 @@ function(_get_common_test_compile_options output_var c_test flags)
     endif()
 
     # list(APPEND compile_options "-Wall")
-    # list(APPEND compile_options "-Wextra")
+    list(APPEND compile_options "-Wextra")
     # -DLIBC_WNO_ERROR=ON if you can't build cleanly with -Werror.
     if(NOT LIBC_WNO_ERROR)
       # list(APPEND compile_options "-Werror")

diff  --git a/libc/test/UnitTest/FPExceptMatcher.cpp b/libc/test/UnitTest/FPExceptMatcher.cpp
index d66066023984e..9688d53496f94 100644
--- a/libc/test/UnitTest/FPExceptMatcher.cpp
+++ b/libc/test/UnitTest/FPExceptMatcher.cpp
@@ -31,7 +31,7 @@ namespace testing {
 static thread_local sigjmp_buf jumpBuffer;
 static thread_local bool caughtExcept;
 
-static void sigfpeHandler(int sig) {
+static void sigfpeHandler([[maybe_unused]] int sig) {
   caughtExcept = true;
   siglongjmp(jumpBuffer, -1);
 }

diff  --git a/libc/test/UnitTest/FPExceptMatcher.h b/libc/test/UnitTest/FPExceptMatcher.h
index 978501df7e3ed..9b05e83bc1e3a 100644
--- a/libc/test/UnitTest/FPExceptMatcher.h
+++ b/libc/test/UnitTest/FPExceptMatcher.h
@@ -43,7 +43,7 @@ class FPExceptMatcher : public Matcher<bool> {
   // Takes ownership of func.
   explicit FPExceptMatcher(FunctionCaller *func);
 
-  bool match(bool unused) { return exceptionRaised; }
+  bool match([[maybe_unused]] bool unused) { return exceptionRaised; }
 
   void explainError() override {
     tlog << "A floating point exception should have been raised but it "

diff  --git a/libc/test/UnitTest/HermeticTestUtils.cpp b/libc/test/UnitTest/HermeticTestUtils.cpp
index f34a73f3e6805..3c82d1e963643 100644
--- a/libc/test/UnitTest/HermeticTestUtils.cpp
+++ b/libc/test/UnitTest/HermeticTestUtils.cpp
@@ -29,7 +29,9 @@ int atexit(void (*func)(void));
 // add_libc_hermetic_test properly. Such that they won't get correct linkage
 // against the object containing this function. We create a dummy function that
 // always returns 0 to indicate a failure.
-[[gnu::weak]] unsigned long getauxval(unsigned long id) { return 0; }
+[[gnu::weak]] unsigned long getauxval([[maybe_unused]] unsigned long id) {
+  return 0;
+}
 
 } // namespace LIBC_NAMESPACE_DECL
 
@@ -124,7 +126,7 @@ unsigned long __getauxval(unsigned long id) {
 
 } // extern "C"
 
-void *operator new(size_t size, void *ptr) { return ptr; }
+void *operator new([[maybe_unused]] size_t size, void *ptr) { return ptr; }
 
 void *operator new(size_t size) { return malloc(size); }
 
@@ -136,7 +138,9 @@ void operator delete(void *) {
   __builtin_trap();
 }
 
-void operator delete(void *ptr, size_t size) { __builtin_trap(); }
+void operator delete([[maybe_unused]] void *ptr, [[maybe_unused]] size_t size) {
+  __builtin_trap();
+}
 
 // Defining members in the std namespace is not preferred. But, we do it here
 // so that we can use it to define the operator new which takes std::align_val_t
@@ -145,8 +149,11 @@ namespace std {
 enum class align_val_t : size_t {};
 } // namespace std
 
-void operator delete(void *mem, std::align_val_t) noexcept { __builtin_trap(); }
+void operator delete([[maybe_unused]] void *mem, std::align_val_t) noexcept {
+  __builtin_trap();
+}
 
-void operator delete(void *mem, unsigned int, std::align_val_t) noexcept {
+void operator delete([[maybe_unused]] void *mem, unsigned int,
+                     std::align_val_t) noexcept {
   __builtin_trap();
 }

diff  --git a/libc/test/UnitTest/LibcDeathTestExecutors.cpp b/libc/test/UnitTest/LibcDeathTestExecutors.cpp
index 943e2c23c5fde..5f8d7b86a5187 100644
--- a/libc/test/UnitTest/LibcDeathTestExecutors.cpp
+++ b/libc/test/UnitTest/LibcDeathTestExecutors.cpp
@@ -22,7 +22,8 @@ namespace LIBC_NAMESPACE_DECL {
 namespace testing {
 
 bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
-                             const char *LHSStr, const char *RHSStr,
+                             const char *LHSStr,
+                             [[maybe_unused]] const char *RHSStr,
                              internal::Location Loc) {
   testutils::ProcessStatus Result =
       testutils::invoke_in_subprocess(Func, TIMEOUT_MS);

diff  --git a/libc/test/UnitTest/LibcTest.h b/libc/test/UnitTest/LibcTest.h
index fbeafd0bacb75..5762b49b6066b 100644
--- a/libc/test/UnitTest/LibcTest.h
+++ b/libc/test/UnitTest/LibcTest.h
@@ -81,7 +81,7 @@ struct Message {
 // A trivial object to catch the Message, this enables custom logging and
 // returning from the test function, see LIBC_TEST_SCAFFOLDING_ below.
 struct Failure {
-  void operator=(Message msg) {}
+  void operator=([[maybe_unused]] Message msg) {}
 };
 
 struct RunContext {

diff  --git a/libc/test/include/stdbit_stub.h b/libc/test/include/stdbit_stub.h
index 3d2e0fb60334e..e08c86271332e 100644
--- a/libc/test/include/stdbit_stub.h
+++ b/libc/test/include/stdbit_stub.h
@@ -17,11 +17,21 @@
 #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([[maybe_unused]] unsigned char x) {                  \
+    return LEADING_VAL##AU;                                                    \
+  }                                                                            \
+  unsigned FUNC_NAME##_us([[maybe_unused]] unsigned short x) {                 \
+    return LEADING_VAL##BU;                                                    \
+  }                                                                            \
+  unsigned FUNC_NAME##_ui([[maybe_unused]] unsigned int x) {                   \
+    return LEADING_VAL##CU;                                                    \
+  }                                                                            \
+  unsigned FUNC_NAME##_ul([[maybe_unused]] unsigned long x) {                  \
+    return LEADING_VAL##DU;                                                    \
+  }                                                                            \
+  unsigned FUNC_NAME##_ull([[maybe_unused]] unsigned long long x) {            \
+    return LEADING_VAL##EU;                                                    \
+  }
 
 __BEGIN_C_DECLS
 
@@ -36,24 +46,42 @@ 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) { 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; }
+bool stdc_has_single_bit_uc([[maybe_unused]] unsigned char x) { return false; }
+bool stdc_has_single_bit_us([[maybe_unused]] unsigned short x) { return false; }
+bool stdc_has_single_bit_ui([[maybe_unused]] unsigned x) { return false; }
+bool stdc_has_single_bit_ul([[maybe_unused]] unsigned long x) { return false; }
+bool stdc_has_single_bit_ull([[maybe_unused]] unsigned long long x) {
+  return false;
+}
 
 STDBIT_STUB_FUNCTION(stdc_bit_width, 0x4)
 
-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) { 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 char stdc_bit_floor_uc([[maybe_unused]] unsigned char x) {
+  return 0x5AU;
+}
+unsigned short stdc_bit_floor_us([[maybe_unused]] unsigned short x) {
+  return 0x5BU;
+}
+unsigned stdc_bit_floor_ui([[maybe_unused]] unsigned x) { return 0x5CU; }
+unsigned long stdc_bit_floor_ul([[maybe_unused]] unsigned long x) {
+  return 0x5DUL;
+}
+unsigned long long stdc_bit_floor_ull([[maybe_unused]] unsigned long long x) {
+  return 0x5EULL;
+}
+
+unsigned char stdc_bit_ceil_uc([[maybe_unused]] unsigned char x) {
+  return 0x6AU;
+}
+unsigned short stdc_bit_ceil_us([[maybe_unused]] unsigned short x) {
+  return 0x6BU;
+}
+unsigned stdc_bit_ceil_ui([[maybe_unused]] unsigned x) { return 0x6CU; }
+unsigned long stdc_bit_ceil_ul([[maybe_unused]] unsigned long x) {
+  return 0x6DUL;
+}
+unsigned long long stdc_bit_ceil_ull([[maybe_unused]] unsigned long long x) {
+  return 0x6EULL;
+}
 
 __END_C_DECLS

diff  --git a/libc/test/integration/src/pthread/pthread_mutex_test.cpp b/libc/test/integration/src/pthread/pthread_mutex_test.cpp
index d41ad6daf426d..d482dcc13f443 100644
--- a/libc/test/integration/src/pthread/pthread_mutex_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_mutex_test.cpp
@@ -23,7 +23,7 @@ constexpr int MAX = 10000;
 pthread_mutex_t mutex;
 static int shared_int = START;
 
-void *counter(void *arg) {
+void *counter([[maybe_unused]] void *arg) {
   int last_count = START;
   while (true) {
     LIBC_NAMESPACE::pthread_mutex_lock(&mutex);
@@ -72,7 +72,7 @@ void relay_counter() {
 pthread_mutex_t start_lock, step_lock;
 bool started, step;
 
-void *stepper(void *arg) {
+void *stepper([[maybe_unused]] void *arg) {
   LIBC_NAMESPACE::pthread_mutex_lock(&start_lock);
   started = true;
   LIBC_NAMESPACE::pthread_mutex_unlock(&start_lock);

diff  --git a/libc/test/integration/src/spawn/posix_spawn_test.cpp b/libc/test/integration/src/spawn/posix_spawn_test.cpp
index 3c8cc7317b537..9e10ef1d5ec15 100644
--- a/libc/test/integration/src/spawn/posix_spawn_test.cpp
+++ b/libc/test/integration/src/spawn/posix_spawn_test.cpp
@@ -45,7 +45,8 @@ void spawn_and_wait_for_normal_exit(char **envp) {
   ASSERT_EQ(exit_status, 0);
 }
 
-TEST_MAIN(int argc, char **argv, char **envp) {
+TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
+          char **envp) {
   spawn_and_wait_for_normal_exit(envp);
   return 0;
 }

diff  --git a/libc/test/integration/src/spawn/posix_spawn_test_binary.cpp b/libc/test/integration/src/spawn/posix_spawn_test_binary.cpp
index c1b0cd671da71..f25337affaf16 100644
--- a/libc/test/integration/src/spawn/posix_spawn_test_binary.cpp
+++ b/libc/test/integration/src/spawn/posix_spawn_test_binary.cpp
@@ -2,7 +2,7 @@
 #include <string.h>
 #include <unistd.h>
 
-int main(int argc, char **argv) {
+int main(int argc, [[maybe_unused]] char **argv) {
   if (argc != 1)
     return 5;
   constexpr size_t bufsize = sizeof(TEXT);

diff  --git a/libc/test/integration/src/stdio/sprintf_size_test.cpp b/libc/test/integration/src/stdio/sprintf_size_test.cpp
index 833159436d49c..ac1f085d330dc 100644
--- a/libc/test/integration/src/stdio/sprintf_size_test.cpp
+++ b/libc/test/integration/src/stdio/sprintf_size_test.cpp
@@ -38,7 +38,7 @@ static int my_strlen(const char *str) {
   return static_cast<int>(other - str);
 }
 
-TEST_MAIN(int argc, char **argv, char **envp) {
+TEST_MAIN(int argc, char **argv, [[maybe_unused]] char **envp) {
   ASSERT_EQ(argc, 5);
   ASSERT_TRUE(my_streq(argv[1], "%s %c %d"));
   ASSERT_EQ(my_strlen(argv[1]), 8);

diff  --git a/libc/test/integration/src/stdlib/getenv_test.cpp b/libc/test/integration/src/stdlib/getenv_test.cpp
index 82a9b89533d2e..72dcea0ddf1f1 100644
--- a/libc/test/integration/src/stdlib/getenv_test.cpp
+++ b/libc/test/integration/src/stdlib/getenv_test.cpp
@@ -27,7 +27,8 @@ static bool my_streq(const char *lhs, const char *rhs) {
   return *l == '\0' && *r == '\0';
 }
 
-TEST_MAIN(int argc, char **argv, char **envp) {
+TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
+          [[maybe_unused]] char **envp) {
   ASSERT_TRUE(
       my_streq(LIBC_NAMESPACE::getenv(""), static_cast<char *>(nullptr)));
   ASSERT_TRUE(

diff  --git a/libc/test/integration/src/threads/cnd_test.cpp b/libc/test/integration/src/threads/cnd_test.cpp
index 8791c6adbaa69..4eaab9ac08bc1 100644
--- a/libc/test/integration/src/threads/cnd_test.cpp
+++ b/libc/test/integration/src/threads/cnd_test.cpp
@@ -100,7 +100,7 @@ namespace single_waiter_test {
 mtx_t waiter_mtx, main_thread_mtx;
 cnd_t waiter_cnd, main_thread_cnd;
 
-int waiter_thread_func(void *unused) {
+int waiter_thread_func([[maybe_unused]] void *unused) {
   LIBC_NAMESPACE::mtx_lock(&waiter_mtx);
 
   LIBC_NAMESPACE::mtx_lock(&main_thread_mtx);

diff  --git a/libc/test/integration/src/threads/mtx_test.cpp b/libc/test/integration/src/threads/mtx_test.cpp
index 82b0350af97af..0b0a9faae24a6 100644
--- a/libc/test/integration/src/threads/mtx_test.cpp
+++ b/libc/test/integration/src/threads/mtx_test.cpp
@@ -23,7 +23,7 @@ constexpr int MAX = 10000;
 mtx_t mutex;
 static int shared_int = START;
 
-int counter(void *arg) {
+int counter([[maybe_unused]] void *arg) {
   int last_count = START;
   while (true) {
     LIBC_NAMESPACE::mtx_lock(&mutex);
@@ -74,7 +74,7 @@ void relay_counter() {
 mtx_t start_lock, step_lock;
 bool started, step;
 
-int stepper(void *arg) {
+int stepper([[maybe_unused]] void *arg) {
   LIBC_NAMESPACE::mtx_lock(&start_lock);
   started = true;
   LIBC_NAMESPACE::mtx_unlock(&start_lock);

diff  --git a/libc/test/integration/src/unistd/execv_test.cpp b/libc/test/integration/src/unistd/execv_test.cpp
index 254ef955f2720..bdd54d420760c 100644
--- a/libc/test/integration/src/unistd/execv_test.cpp
+++ b/libc/test/integration/src/unistd/execv_test.cpp
@@ -52,7 +52,8 @@ void fork_and_execv_signal_exit() {
   ASSERT_TRUE(WTERMSIG(status) == SIGUSR1);
 }
 
-TEST_MAIN(int argc, char **argv, char **envp) {
+TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
+          [[maybe_unused]] char **envp) {
   fork_and_execv_normal_exit();
   fork_and_execv_signal_exit();
   return 0;

diff  --git a/libc/test/integration/src/unistd/execve_test.cpp b/libc/test/integration/src/unistd/execve_test.cpp
index fb1a83da63856..1204de3984c7e 100644
--- a/libc/test/integration/src/unistd/execve_test.cpp
+++ b/libc/test/integration/src/unistd/execve_test.cpp
@@ -52,7 +52,8 @@ void fork_and_execv_signal_exit(char **envp) {
   ASSERT_TRUE(WTERMSIG(status) == SIGUSR1);
 }
 
-TEST_MAIN(int argc, char **argv, char **envp) {
+TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
+          char **envp) {
   fork_and_execv_normal_exit(envp);
   fork_and_execv_signal_exit(envp);
   return 0;

diff  --git a/libc/test/integration/src/unistd/fork_test.cpp b/libc/test/integration/src/unistd/fork_test.cpp
index 010f57a7d2448..7eeefa4477806 100644
--- a/libc/test/integration/src/unistd/fork_test.cpp
+++ b/libc/test/integration/src/unistd/fork_test.cpp
@@ -159,7 +159,8 @@ void gettid_test() {
   ASSERT_EQ(WEXITSTATUS(status), 0);
 }
 
-TEST_MAIN(int argc, char **argv, char **envp) {
+TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
+          [[maybe_unused]] char **envp) {
   gettid_test();
   fork_and_wait_normal_exit();
   fork_and_wait4_normal_exit();

diff  --git a/libc/test/integration/src/unistd/getcwd_test.cpp b/libc/test/integration/src/unistd/getcwd_test.cpp
index 1b321b01e9315..5e5c0fa83a3cb 100644
--- a/libc/test/integration/src/unistd/getcwd_test.cpp
+++ b/libc/test/integration/src/unistd/getcwd_test.cpp
@@ -17,7 +17,8 @@
 
 using LIBC_NAMESPACE::cpp::string_view;
 
-TEST_MAIN(int argc, char **argv, char **envp) {
+TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
+          [[maybe_unused]] char **envp) {
   char buffer[1024];
   ASSERT_TRUE(string_view(LIBC_NAMESPACE::getenv("PWD")) ==
               LIBC_NAMESPACE::getcwd(buffer, 1024));

diff  --git a/libc/test/integration/startup/linux/main_without_envp.cpp b/libc/test/integration/startup/linux/main_without_envp.cpp
index d2c24f4bd9f14..894f43083faee 100644
--- a/libc/test/integration/startup/linux/main_without_envp.cpp
+++ b/libc/test/integration/startup/linux/main_without_envp.cpp
@@ -8,4 +8,4 @@
 
 #include "test/IntegrationTest/test.h"
 
-TEST_MAIN(int argc, char **argv) { return 0; }
+TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv) { return 0; }

diff  --git a/libc/test/integration/startup/linux/tls_test.cpp b/libc/test/integration/startup/linux/tls_test.cpp
index de3bd06c39cf6..097c8cd0967d9 100644
--- a/libc/test/integration/startup/linux/tls_test.cpp
+++ b/libc/test/integration/startup/linux/tls_test.cpp
@@ -15,7 +15,8 @@
 constexpr int threadLocalDataSize = 101;
 _Thread_local int a[threadLocalDataSize] = {123};
 
-TEST_MAIN(int argc, char **argv, char **envp) {
+TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
+          [[maybe_unused]] char **envp) {
   ASSERT_TRUE(a[0] == 123);
 
   for (int i = 1; i < threadLocalDataSize; ++i)

diff  --git a/libc/test/src/__support/CPP/integer_sequence_test.cpp b/libc/test/src/__support/CPP/integer_sequence_test.cpp
index fe378522b446b..590fb4ede4cda 100644
--- a/libc/test/src/__support/CPP/integer_sequence_test.cpp
+++ b/libc/test/src/__support/CPP/integer_sequence_test.cpp
@@ -23,7 +23,8 @@ TEST(LlvmLibcIntegerSequencetTest, Basic) {
       (is_same_v<ULLSeq, make_integer_sequence<unsigned long long, 4>>));
 }
 
-template <typename T, T... Ts> bool checkArray(integer_sequence<T, Ts...> seq) {
+template <typename T, T... Ts>
+bool checkArray([[maybe_unused]] integer_sequence<T, Ts...> seq) {
   T arr[sizeof...(Ts)]{Ts...};
 
   for (T i = 0; i < static_cast<T>(sizeof...(Ts)); i++)

diff  --git a/libc/test/src/__support/freelist_heap_test.cpp b/libc/test/src/__support/freelist_heap_test.cpp
index 93e23619661a0..ea7310d1d0756 100644
--- a/libc/test/src/__support/freelist_heap_test.cpp
+++ b/libc/test/src/__support/freelist_heap_test.cpp
@@ -57,7 +57,7 @@ using LIBC_NAMESPACE::cpp::span;
     RunTest(*freelist_heap, freelist_heap->region().size());                   \
   }                                                                            \
   void LlvmLibcFreeListHeapTest##TestCase::RunTest(FreeListHeap &allocator,    \
-                                                   size_t N)
+                                                   [[maybe_unused]] size_t N)
 
 TEST_FOR_EACH_ALLOCATOR(CanAllocate, 2048) {
   constexpr size_t ALLOC_SIZE = 512;

diff  --git a/libc/test/src/math/exhaustive/hypotf16_test.cpp b/libc/test/src/math/exhaustive/hypotf16_test.cpp
index f79041e6dbd77..a822fc433d170 100644
--- a/libc/test/src/math/exhaustive/hypotf16_test.cpp
+++ b/libc/test/src/math/exhaustive/hypotf16_test.cpp
@@ -20,8 +20,9 @@ struct Hypotf16Checker : public virtual LIBC_NAMESPACE::testing::Test {
   using FPBits = LIBC_NAMESPACE::fputil::FPBits<float16>;
   using StorageType = typename FPBits::StorageType;
 
-  uint64_t check(uint16_t x_start, uint16_t x_stop, uint16_t y_start,
-                 uint16_t y_stop, mpfr::RoundingMode rounding) {
+  uint64_t check(uint16_t x_start, uint16_t x_stop,
+                 [[maybe_unused]] uint16_t y_start, uint16_t y_stop,
+                 mpfr::RoundingMode rounding) {
     mpfr::ForceRoundingMode r(rounding);
     if (!r.success)
       return true;

diff  --git a/libc/test/src/stdlib/StrfromTest.h b/libc/test/src/stdlib/StrfromTest.h
index 197165c68d587..e82c94499aa11 100644
--- a/libc/test/src/stdlib/StrfromTest.h
+++ b/libc/test/src/stdlib/StrfromTest.h
@@ -357,7 +357,7 @@ class StrfromTest : public LIBC_NAMESPACE::testing::Test {
     ASSERT_STREQ_LEN(written, buff, "1.0e+01");
   }
 
-  void floatDecimalExpLongDoublePrec(FunctionT func) {
+  void floatDecimalExpLongDoublePrec([[maybe_unused]] FunctionT func) {
     // Mark as maybe_unused to silence unused variable
     // warning when long double is not 80-bit
     [[maybe_unused]] char buff[100];
@@ -422,7 +422,7 @@ class StrfromTest : public LIBC_NAMESPACE::testing::Test {
     ASSERT_STREQ_LEN(written, buff, "1.2340000000000000814e-10");
   }
 
-  void floatDecimalAutoLongDoublePrec(FunctionT func) {
+  void floatDecimalAutoLongDoublePrec([[maybe_unused]] FunctionT func) {
     // Mark as maybe_unused to silence unused variable
     // warning when long double is not 80-bit
     [[maybe_unused]] char buff[100];

diff  --git a/libc/test/src/string/memory_utils/op_tests.cpp b/libc/test/src/string/memory_utils/op_tests.cpp
index 2057ab3eaaded..06089a89d9aac 100644
--- a/libc/test/src/string/memory_utils/op_tests.cpp
+++ b/libc/test/src/string/memory_utils/op_tests.cpp
@@ -72,7 +72,8 @@ void CopyAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {
   FnImpl(as_byte(dst), as_byte(src), size);
 }
 template <size_t Size, auto FnImpl>
-void CopyBlockAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {
+void CopyBlockAdaptor(cpp::span<char> dst, cpp::span<char> src,
+                      [[maybe_unused]] size_t size) {
   FnImpl(as_byte(dst), as_byte(src));
 }
 
@@ -153,7 +154,8 @@ void SetAdaptor(cpp::span<char> dst, uint8_t value, size_t size) {
   FnImpl(as_byte(dst), value, size);
 }
 template <size_t Size, auto FnImpl>
-void SetBlockAdaptor(cpp::span<char> dst, uint8_t value, size_t size) {
+void SetBlockAdaptor(cpp::span<char> dst, uint8_t value,
+                     [[maybe_unused]] size_t size) {
   FnImpl(as_byte(dst), value);
 }
 
@@ -242,7 +244,8 @@ int CmpAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {
   return (int)FnImpl(as_byte(p1), as_byte(p2), size);
 }
 template <size_t Size, auto FnImpl>
-int CmpBlockAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {
+int CmpBlockAdaptor(cpp::span<char> p1, cpp::span<char> p2,
+                    [[maybe_unused]] size_t size) {
   return (int)FnImpl(as_byte(p1), as_byte(p2));
 }
 

diff  --git a/libc/test/src/strings/bzero_test.cpp b/libc/test/src/strings/bzero_test.cpp
index 4d4112f4be8ee..a09d711bcb2e6 100644
--- a/libc/test/src/strings/bzero_test.cpp
+++ b/libc/test/src/strings/bzero_test.cpp
@@ -14,7 +14,8 @@
 namespace LIBC_NAMESPACE_DECL {
 
 // Adapt CheckMemset signature to bzero.
-static inline void Adaptor(cpp::span<char> p1, uint8_t value, size_t size) {
+static inline void Adaptor(cpp::span<char> p1, [[maybe_unused]] uint8_t value,
+                           size_t size) {
   LIBC_NAMESPACE::bzero(p1.begin(), size);
 }
 

diff  --git a/libc/utils/MPFRWrapper/MPFRUtils.h b/libc/utils/MPFRWrapper/MPFRUtils.h
index 45468c6cb19ae..d7b5582203fa5 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.h
+++ b/libc/utils/MPFRWrapper/MPFRUtils.h
@@ -352,7 +352,7 @@ template <Operation op, typename InputType, typename OutputType>
 __attribute__((no_sanitize("address"))) cpp::enable_if_t<
     is_valid_operation<op, InputType, OutputType>(),
     internal::MPFRMatcher<op, /*is_silent*/ false, InputType, OutputType>>
-get_mpfr_matcher(InputType input, OutputType output_unused,
+get_mpfr_matcher(InputType input, [[maybe_unused]] OutputType output_unused,
                  double ulp_tolerance, RoundingMode rounding) {
   return internal::MPFRMatcher<op, /*is_silent*/ false, InputType, OutputType>(
       input, ulp_tolerance, rounding);
@@ -362,7 +362,8 @@ template <Operation op, typename InputType, typename OutputType>
 __attribute__((no_sanitize("address"))) cpp::enable_if_t<
     is_valid_operation<op, InputType, OutputType>(),
     internal::MPFRMatcher<op, /*is_silent*/ true, InputType, OutputType>>
-get_silent_mpfr_matcher(InputType input, OutputType output_unused,
+get_silent_mpfr_matcher(InputType input,
+                        [[maybe_unused]] OutputType output_unused,
                         double ulp_tolerance, RoundingMode rounding) {
   return internal::MPFRMatcher<op, /*is_silent*/ true, InputType, OutputType>(
       input, ulp_tolerance, rounding);


        


More information about the libc-commits mailing list