[libc-commits] [libc] [libc] Fix -Wunused-variable warnings (PR #241982)

Victor Campos via libc-commits libc-commits at lists.llvm.org
Fri Nov 13 02:11:49 PST 2026


https://github.com/vhscampos updated https://github.com/llvm/llvm-project/pull/241982

>From bf1463b166827be4a3e0349fb60d6d8487b87c84 Mon Sep 17 00:00:00 2001
From: Victor Campos <victor.campos at arm.com>
Date: Thu, 12 Nov 2026 17:43:22 +0000
Subject: [PATCH] [libc] Fix -Wunused-variable warnings

These variables may end up unused depending on the rounding mode in
place.
---
 libc/test/src/math/smoke/exp10f16_test.cpp   | 2 +-
 libc/test/src/math/smoke/exp10m1f16_test.cpp | 2 +-
 libc/test/src/math/smoke/exp2f16_test.cpp    | 2 +-
 libc/test/src/math/smoke/exp2m1f16_test.cpp  | 2 +-
 libc/test/src/math/smoke/expf16_test.cpp     | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libc/test/src/math/smoke/exp10f16_test.cpp b/libc/test/src/math/smoke/exp10f16_test.cpp
index b51bad0110e05..a5383779587db 100644
--- a/libc/test/src/math/smoke/exp10f16_test.cpp
+++ b/libc/test/src/math/smoke/exp10f16_test.cpp
@@ -63,7 +63,7 @@ TEST_F(LlvmLibcExp10f16Test, Underflow) {
 TEST_F(LlvmLibcExp10f16Test, OverflowStatusAllRoundingModes) {
   using Bits = LIBC_NAMESPACE::fputil::FPBits<float16>;
   const float16 x = Bits(uint16_t(0x5000)).get_val();
-  const float16 largest = Bits(uint16_t(0x7bff)).get_val();
+  [[maybe_unused]] const float16 largest = Bits(uint16_t(0x7bff)).get_val();
   const float16 infinity = Bits::inf().get_val();
   EXPECT_FP_EQ_WITH_EXCEPTION_ROUNDING_NEAREST(
       infinity, LIBC_NAMESPACE::exp10f16(x), FE_OVERFLOW | FE_INEXACT);
diff --git a/libc/test/src/math/smoke/exp10m1f16_test.cpp b/libc/test/src/math/smoke/exp10m1f16_test.cpp
index 1fbd8c257fbcd..1fc139290d1f0 100644
--- a/libc/test/src/math/smoke/exp10m1f16_test.cpp
+++ b/libc/test/src/math/smoke/exp10m1f16_test.cpp
@@ -109,7 +109,7 @@ TEST_F(LlvmLibcExp10m1f16Test, ResultNearNegOne) {
 TEST_F(LlvmLibcExp10m1f16Test, OverflowStatusAllRoundingModes) {
   using Bits = LIBC_NAMESPACE::fputil::FPBits<float16>;
   const float16 x = Bits(uint16_t(0x5000)).get_val();
-  const float16 largest = Bits(uint16_t(0x7bff)).get_val();
+  [[maybe_unused]] const float16 largest = Bits(uint16_t(0x7bff)).get_val();
   const float16 infinity = Bits::inf().get_val();
   EXPECT_FP_EQ_WITH_EXCEPTION_ROUNDING_NEAREST(
       infinity, LIBC_NAMESPACE::exp10m1f16(x), FE_OVERFLOW | FE_INEXACT);
diff --git a/libc/test/src/math/smoke/exp2f16_test.cpp b/libc/test/src/math/smoke/exp2f16_test.cpp
index 07e2e23dcff05..68aea9256f925 100644
--- a/libc/test/src/math/smoke/exp2f16_test.cpp
+++ b/libc/test/src/math/smoke/exp2f16_test.cpp
@@ -63,7 +63,7 @@ TEST_F(LlvmLibcExp2f16Test, Underflow) {
 TEST_F(LlvmLibcExp2f16Test, OverflowStatusAllRoundingModes) {
   using Bits = LIBC_NAMESPACE::fputil::FPBits<float16>;
   const float16 x = Bits(uint16_t(0x5000)).get_val();
-  const float16 largest = Bits(uint16_t(0x7bff)).get_val();
+  [[maybe_unused]] const float16 largest = Bits(uint16_t(0x7bff)).get_val();
   const float16 infinity = Bits::inf().get_val();
   EXPECT_FP_EQ_WITH_EXCEPTION_ROUNDING_NEAREST(
       infinity, LIBC_NAMESPACE::exp2f16(x), FE_OVERFLOW | FE_INEXACT);
diff --git a/libc/test/src/math/smoke/exp2m1f16_test.cpp b/libc/test/src/math/smoke/exp2m1f16_test.cpp
index e096024def61b..b7e7f80a6cb01 100644
--- a/libc/test/src/math/smoke/exp2m1f16_test.cpp
+++ b/libc/test/src/math/smoke/exp2m1f16_test.cpp
@@ -111,7 +111,7 @@ TEST_F(LlvmLibcExp2m1f16Test, ResultNearNegOne) {
 TEST_F(LlvmLibcExp2m1f16Test, OverflowStatusAllRoundingModes) {
   using Bits = LIBC_NAMESPACE::fputil::FPBits<float16>;
   const float16 x = Bits(uint16_t(0x5000)).get_val();
-  const float16 largest = Bits(uint16_t(0x7bff)).get_val();
+  [[maybe_unused]] const float16 largest = Bits(uint16_t(0x7bff)).get_val();
   const float16 infinity = Bits::inf().get_val();
   EXPECT_FP_EQ_WITH_EXCEPTION_ROUNDING_NEAREST(
       infinity, LIBC_NAMESPACE::exp2m1f16(x), FE_OVERFLOW | FE_INEXACT);
diff --git a/libc/test/src/math/smoke/expf16_test.cpp b/libc/test/src/math/smoke/expf16_test.cpp
index aa0d4314a3dda..e4a45136893e8 100644
--- a/libc/test/src/math/smoke/expf16_test.cpp
+++ b/libc/test/src/math/smoke/expf16_test.cpp
@@ -63,7 +63,7 @@ TEST_F(LlvmLibcExpf16Test, Underflow) {
 TEST_F(LlvmLibcExpf16Test, OverflowStatusAllRoundingModes) {
   using Bits = LIBC_NAMESPACE::fputil::FPBits<float16>;
   const float16 x = Bits(uint16_t(0x5000)).get_val();
-  const float16 largest = Bits(uint16_t(0x7bff)).get_val();
+  [[maybe_unused]] const float16 largest = Bits(uint16_t(0x7bff)).get_val();
   const float16 infinity = Bits::inf().get_val();
   EXPECT_FP_EQ_WITH_EXCEPTION_ROUNDING_NEAREST(
       infinity, LIBC_NAMESPACE::expf16(x), FE_OVERFLOW | FE_INEXACT);



More information about the libc-commits mailing list