Skip to content

[libc] Fix implicit conversion warnings in tests. #131362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2025
Merged

Conversation

lntue
Copy link
Contributor

@lntue lntue commented Mar 14, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Mar 14, 2025

@llvm/pr-subscribers-libc

Author: None (lntue)

Changes

Patch is 50.82 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/131362.diff

32 Files Affected:

  • (modified) libc/src/__support/big_int.h (+2-2)
  • (modified) libc/test/integration/src/pthread/pthread_rwlock_test.cpp (+2-2)
  • (modified) libc/test/src/__support/HashTable/table_test.cpp (+2-2)
  • (modified) libc/test/src/__support/arg_list_test.cpp (+1-2)
  • (modified) libc/test/src/__support/fixed_point/fx_bits_test.cpp (+1-1)
  • (modified) libc/test/src/complex/CImagTest.h (+8-8)
  • (modified) libc/test/src/complex/CRealTest.h (+8-8)
  • (modified) libc/test/src/fcntl/openat_test.cpp (+1-1)
  • (modified) libc/test/src/math/CopySignTest.h (+2-2)
  • (modified) libc/test/src/math/FMaxTest.h (+10-10)
  • (modified) libc/test/src/math/FMinTest.h (+10-10)
  • (modified) libc/test/src/math/FrexpTest.h (+2-2)
  • (modified) libc/test/src/math/NextAfterTest.h (+1-1)
  • (modified) libc/test/src/math/exhaustive/exhaustive_test.h (+2-1)
  • (modified) libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp (+2-2)
  • (modified) libc/test/src/math/smoke/NextAfterTest.h (+1-1)
  • (modified) libc/test/src/math/smoke/NextTowardTest.h (+1-1)
  • (modified) libc/test/src/stdio/fileop_test.cpp (+1-1)
  • (modified) libc/test/src/stdio/sscanf_test.cpp (+32-32)
  • (modified) libc/test/src/stdlib/StrfromTest.h (+26-26)
  • (modified) libc/test/src/string/memcpy_test.cpp (+1-1)
  • (modified) libc/test/src/sys/random/linux/getrandom_test.cpp (+6-4)
  • (modified) libc/test/src/sys/uio/readv_test.cpp (+2-2)
  • (modified) libc/test/src/sys/uio/writev_test.cpp (+2-2)
  • (modified) libc/test/src/time/strftime_test.cpp (+34-36)
  • (modified) libc/test/src/unistd/lseek_test.cpp (+4-4)
  • (modified) libc/test/src/unistd/pread_pwrite_test.cpp (+4-4)
  • (modified) libc/test/src/unistd/read_write_test.cpp (+5-5)
  • (modified) libc/test/src/unistd/readlink_test.cpp (+1-1)
  • (modified) libc/test/src/unistd/readlinkat_test.cpp (+1-1)
  • (modified) libc/test/src/unistd/syscall_test.cpp (+16-16)
  • (modified) libc/utils/MPFRWrapper/MPCommon.cpp (+2-2)
diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h
index fa06bb485de2c..85db31d01399a 100644
--- a/libc/src/__support/big_int.h
+++ b/libc/src/__support/big_int.h
@@ -866,7 +866,7 @@ struct BigInt {
   LIBC_INLINE constexpr BigInt operator~() const {
     BigInt result;
     for (size_t i = 0; i < WORD_COUNT; ++i)
-      result[i] = ~val[i];
+      result[i] = static_cast<WordType>(~val[i]);
     return result;
   }
 
@@ -967,7 +967,7 @@ struct BigInt {
 
   LIBC_INLINE constexpr void bitwise_not() {
     for (auto &part : val)
-      part = ~part;
+      part = static_cast<WordType>(~part);
   }
 
   LIBC_INLINE constexpr void negate() {
diff --git a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
index 4cd4255a333e6..205e9f74ea9a1 100644
--- a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
@@ -324,8 +324,8 @@ struct ThreadGuard {
   ~ThreadGuard() {
     if (!LIBC_NAMESPACE::getenv("LIBC_PTHREAD_RWLOCK_TEST_VERBOSE"))
       return;
-    pid_t pid = LIBC_NAMESPACE::syscall_impl(SYS_getpid);
-    pid_t tid = LIBC_NAMESPACE::syscall_impl(SYS_gettid);
+    pid_t pid = static_cast<pid_t>(LIBC_NAMESPACE::syscall_impl(SYS_getpid));
+    pid_t tid = static_cast<pid_t>(LIBC_NAMESPACE::syscall_impl(SYS_gettid));
     io_mutex->lock(LIBC_NAMESPACE::cpp::nullopt, true);
     LIBC_NAMESPACE::printf("process %d thread %d: ", pid, tid);
     for (size_t i = 0; i < cursor; ++i)
diff --git a/libc/test/src/__support/HashTable/table_test.cpp b/libc/test/src/__support/HashTable/table_test.cpp
index c3b8697f2087a..a579bfabb2d7b 100644
--- a/libc/test/src/__support/HashTable/table_test.cpp
+++ b/libc/test/src/__support/HashTable/table_test.cpp
@@ -43,11 +43,11 @@ TEST(LlvmLibcTableTest, Iteration) {
     counter[i] = 0;
     if (i >= 256) {
       keys[i].bytes[0] = 2;
-      keys[i].bytes[1] = i % 256;
+      keys[i].bytes[1] = static_cast<uint8_t>(i % 256);
       keys[i].bytes[2] = 0;
     } else {
       keys[i].bytes[0] = 1;
-      keys[i].bytes[1] = i;
+      keys[i].bytes[1] = static_cast<uint8_t>(i);
       keys[i].bytes[2] = 0;
     }
     HashTable::insert(table, {reinterpret_cast<char *>(keys[i].bytes),
diff --git a/libc/test/src/__support/arg_list_test.cpp b/libc/test/src/__support/arg_list_test.cpp
index 70db0aafa631a..645de261d601f 100644
--- a/libc/test/src/__support/arg_list_test.cpp
+++ b/libc/test/src/__support/arg_list_test.cpp
@@ -112,8 +112,7 @@ long int check_struct_type(int first, ...) {
 
   S s = args.next_var<S>();
   int last = args.next_var<int>();
-  return static_cast<long int>(s.c + s.s + s.i + static_cast<long>(s.l) + s.f +
-                               s.d + last);
+  return s.c + s.s + s.i + s.l + static_cast<long>(s.f + s.d) + last;
 }
 
 TEST(LlvmLibcArgListTest, TestStructTypes) {
diff --git a/libc/test/src/__support/fixed_point/fx_bits_test.cpp b/libc/test/src/__support/fixed_point/fx_bits_test.cpp
index 3cbd800adc3c3..804cfd3fb2bf7 100644
--- a/libc/test/src/__support/fixed_point/fx_bits_test.cpp
+++ b/libc/test/src/__support/fixed_point/fx_bits_test.cpp
@@ -27,7 +27,7 @@ class LlvmLibcFxBitsTest : public LIBC_NAMESPACE::testing::Test {
     EXPECT_EQ(LIBC_NAMESPACE::fixed_point::bit_or(T(0.75), T(0.375)), T(0.875));
     using StorageType = typename FXRep<T>::StorageType;
     StorageType a = LIBC_NAMESPACE::cpp::bit_cast<StorageType>(T(0.75));
-    a = ~a;
+    a = static_cast<StorageType>(~a);
     EXPECT_EQ(LIBC_NAMESPACE::fixed_point::bit_not(T(0.75)),
               FXBits<T>(a).get_val());
   }
diff --git a/libc/test/src/complex/CImagTest.h b/libc/test/src/complex/CImagTest.h
index 408460d97dfc6..e7c1bf4d6a7d6 100644
--- a/libc/test/src/complex/CImagTest.h
+++ b/libc/test/src/complex/CImagTest.h
@@ -38,14 +38,14 @@ class CImagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
                  neg_min_denormal);
     EXPECT_FP_EQ(func(CFPT(1241.112 + max_denormal * 1.0i)), max_denormal);
     EXPECT_FP_EQ(func(CFPT(121.121 + zero * 1.0i)), zero);
-    EXPECT_FP_EQ(func(CFPT(0.0 + 0.0i)), 0.0);
-    EXPECT_FP_EQ(func(CFPT(-0.0 + 0.0i)), 0.0);
-    EXPECT_FP_EQ(func(CFPT(0.0 - 0.0i)), -0.0);
-    EXPECT_FP_EQ(func(CFPT(-0.0 - 0.0i)), -0.0);
-    EXPECT_FP_EQ(func(CFPT(0.0)), 0.0);
-    EXPECT_FP_EQ(func(CFPT(-0.0)), 0.0);
-    EXPECT_FP_EQ(func(CFPT(0.0i)), 0.0);
-    EXPECT_FP_EQ(func(CFPT(-0.0i)), -0.0);
+    EXPECT_FP_EQ(func(CFPT(0.0 + 0.0i)), zero);
+    EXPECT_FP_EQ(func(CFPT(-0.0 + 0.0i)), zero);
+    EXPECT_FP_EQ(func(CFPT(0.0 - 0.0i)), neg_zero);
+    EXPECT_FP_EQ(func(CFPT(-0.0 - 0.0i)), neg_zero);
+    EXPECT_FP_EQ(func(CFPT(0.0)), zero);
+    EXPECT_FP_EQ(func(CFPT(-0.0)), zero);
+    EXPECT_FP_EQ(func(CFPT(0.0i)), zero);
+    EXPECT_FP_EQ(func(CFPT(-0.0i)), neg_zero);
   }
 
   void testRoundedNumbers(CImagFunc func) {
diff --git a/libc/test/src/complex/CRealTest.h b/libc/test/src/complex/CRealTest.h
index 80eafc9975f4c..a1efe7524b5bd 100644
--- a/libc/test/src/complex/CRealTest.h
+++ b/libc/test/src/complex/CRealTest.h
@@ -37,14 +37,14 @@ class CRealTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     EXPECT_FP_EQ(func(CFPT(neg_min_denormal + 781.134i)), neg_min_denormal);
     EXPECT_FP_EQ(func(CFPT(max_denormal + 1241.112i)), max_denormal);
     EXPECT_FP_EQ(func(CFPT(zero + 121.121i)), zero);
-    EXPECT_FP_EQ(func(CFPT(0.0 + 0.0i)), 0.0);
-    EXPECT_FP_EQ(func(CFPT(-0.0 + 0.0i)), 0.0);
-    EXPECT_FP_EQ(func(CFPT(0.0 - 0.0i)), 0.0);
-    EXPECT_FP_EQ(func(CFPT(-0.0 - 0.0i)), -0.0);
-    EXPECT_FP_EQ(func(CFPT(0.0)), 0.0);
-    EXPECT_FP_EQ(func(CFPT(-0.0)), -0.0);
-    EXPECT_FP_EQ(func(CFPT(0.0i)), 0.0);
-    EXPECT_FP_EQ(func(CFPT(-0.0i)), -0.0);
+    EXPECT_FP_EQ(func(CFPT(0.0 + 0.0i)), zero);
+    EXPECT_FP_EQ(func(CFPT(-0.0 + 0.0i)), zero);
+    EXPECT_FP_EQ(func(CFPT(0.0 - 0.0i)), zero);
+    EXPECT_FP_EQ(func(CFPT(-0.0 - 0.0i)), neg_zero);
+    EXPECT_FP_EQ(func(CFPT(0.0)), zero);
+    EXPECT_FP_EQ(func(CFPT(-0.0)), neg_zero);
+    EXPECT_FP_EQ(func(CFPT(0.0i)), zero);
+    EXPECT_FP_EQ(func(CFPT(-0.0i)), neg_zero);
   }
 
   void testRoundedNumbers(CRealFunc func) {
diff --git a/libc/test/src/fcntl/openat_test.cpp b/libc/test/src/fcntl/openat_test.cpp
index 547359eb9f7a9..213b074799c8d 100644
--- a/libc/test/src/fcntl/openat_test.cpp
+++ b/libc/test/src/fcntl/openat_test.cpp
@@ -24,7 +24,7 @@ TEST(LlvmLibcUniStd, OpenAndReadTest) {
   ASSERT_ERRNO_SUCCESS();
   ASSERT_GT(dir_fd, 0);
   constexpr const char TEST_MSG[] = "openat test";
-  constexpr int TEST_MSG_SIZE = sizeof(TEST_MSG) - 1;
+  constexpr ssize_t TEST_MSG_SIZE = sizeof(TEST_MSG) - 1;
 
   int read_fd = LIBC_NAMESPACE::openat(dir_fd, TEST_FILE, O_RDONLY);
   ASSERT_ERRNO_SUCCESS();
diff --git a/libc/test/src/math/CopySignTest.h b/libc/test/src/math/CopySignTest.h
index 8db4f6941e603..7c46d1bbf134f 100644
--- a/libc/test/src/math/CopySignTest.h
+++ b/libc/test/src/math/CopySignTest.h
@@ -42,10 +42,10 @@ class CopySignTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
       if (FPBits(v).is_nan() || FPBits(v).is_inf())
         continue;
 
-      double res1 = func(x, -x);
+      T res1 = func(x, -x);
       ASSERT_FP_EQ(res1, -x);
 
-      double res2 = func(x, x);
+      T res2 = func(x, x);
       ASSERT_FP_EQ(res2, x);
     }
   }
diff --git a/libc/test/src/math/FMaxTest.h b/libc/test/src/math/FMaxTest.h
index 43904a489f76d..772409062ef5a 100644
--- a/libc/test/src/math/FMaxTest.h
+++ b/libc/test/src/math/FMaxTest.h
@@ -29,8 +29,8 @@ class FMaxTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
   void testNaN(FMaxFunc func) {
     EXPECT_FP_EQ(inf, func(aNaN, inf));
     EXPECT_FP_EQ(neg_inf, func(neg_inf, aNaN));
-    EXPECT_FP_EQ(0.0, func(aNaN, 0.0));
-    EXPECT_FP_EQ(-0.0, func(-0.0, aNaN));
+    EXPECT_FP_EQ(zero, func(aNaN, zero));
+    EXPECT_FP_EQ(neg_zero, func(neg_zero, aNaN));
     EXPECT_FP_EQ(T(-1.2345), func(aNaN, T(-1.2345)));
     EXPECT_FP_EQ(T(1.2345), func(T(1.2345), aNaN));
     EXPECT_FP_EQ(aNaN, func(aNaN, aNaN));
@@ -38,25 +38,25 @@ class FMaxTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
   void testInfArg(FMaxFunc func) {
     EXPECT_FP_EQ(inf, func(neg_inf, inf));
-    EXPECT_FP_EQ(inf, func(inf, 0.0));
-    EXPECT_FP_EQ(inf, func(-0.0, inf));
+    EXPECT_FP_EQ(inf, func(inf, zero));
+    EXPECT_FP_EQ(inf, func(neg_zero, inf));
     EXPECT_FP_EQ(inf, func(inf, T(1.2345)));
     EXPECT_FP_EQ(inf, func(T(-1.2345), inf));
   }
 
   void testNegInfArg(FMaxFunc func) {
     EXPECT_FP_EQ(inf, func(inf, neg_inf));
-    EXPECT_FP_EQ(0.0, func(neg_inf, 0.0));
-    EXPECT_FP_EQ(-0.0, func(-0.0, neg_inf));
+    EXPECT_FP_EQ(zero, func(neg_inf, zero));
+    EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_inf));
     EXPECT_FP_EQ(T(-1.2345), func(neg_inf, T(-1.2345)));
     EXPECT_FP_EQ(T(1.2345), func(T(1.2345), neg_inf));
   }
 
   void testBothZero(FMaxFunc func) {
-    EXPECT_FP_EQ(0.0, func(0.0, 0.0));
-    EXPECT_FP_EQ(0.0, func(-0.0, 0.0));
-    EXPECT_FP_EQ(0.0, func(0.0, -0.0));
-    EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+    EXPECT_FP_EQ(zero, func(zero, zero));
+    EXPECT_FP_EQ(zero, func(neg_zero, zero));
+    EXPECT_FP_EQ(zero, func(zero, neg_zero));
+    EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
   }
 
   void testRange(FMaxFunc func) {
diff --git a/libc/test/src/math/FMinTest.h b/libc/test/src/math/FMinTest.h
index 51c21ae56a774..3822d7cb73785 100644
--- a/libc/test/src/math/FMinTest.h
+++ b/libc/test/src/math/FMinTest.h
@@ -30,8 +30,8 @@ class FMinTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
   void testNaN(FMinFunc func) {
     EXPECT_FP_EQ(inf, func(aNaN, inf));
     EXPECT_FP_EQ(neg_inf, func(neg_inf, aNaN));
-    EXPECT_FP_EQ(0.0, func(aNaN, 0.0));
-    EXPECT_FP_EQ(-0.0, func(-0.0, aNaN));
+    EXPECT_FP_EQ(zero, func(aNaN, zero));
+    EXPECT_FP_EQ(neg_zero, func(neg_zero, aNaN));
     EXPECT_FP_EQ(T(-1.2345), func(aNaN, T(-1.2345)));
     EXPECT_FP_EQ(T(1.2345), func(T(1.2345), aNaN));
     EXPECT_FP_EQ(aNaN, func(aNaN, aNaN));
@@ -39,25 +39,25 @@ class FMinTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
   void testInfArg(FMinFunc func) {
     EXPECT_FP_EQ(neg_inf, func(neg_inf, inf));
-    EXPECT_FP_EQ(0.0, func(inf, 0.0));
-    EXPECT_FP_EQ(-0.0, func(-0.0, inf));
+    EXPECT_FP_EQ(zero, func(inf, zero));
+    EXPECT_FP_EQ(neg_zero, func(neg_zero, inf));
     EXPECT_FP_EQ(T(1.2345), func(inf, T(1.2345)));
     EXPECT_FP_EQ(T(-1.2345), func(T(-1.2345), inf));
   }
 
   void testNegInfArg(FMinFunc func) {
     EXPECT_FP_EQ(neg_inf, func(inf, neg_inf));
-    EXPECT_FP_EQ(neg_inf, func(neg_inf, 0.0));
-    EXPECT_FP_EQ(neg_inf, func(-0.0, neg_inf));
+    EXPECT_FP_EQ(neg_inf, func(neg_inf, zero));
+    EXPECT_FP_EQ(neg_inf, func(neg_zero, neg_inf));
     EXPECT_FP_EQ(neg_inf, func(neg_inf, T(-1.2345)));
     EXPECT_FP_EQ(neg_inf, func(T(1.2345), neg_inf));
   }
 
   void testBothZero(FMinFunc func) {
-    EXPECT_FP_EQ(0.0, func(0.0, 0.0));
-    EXPECT_FP_EQ(-0.0, func(-0.0, 0.0));
-    EXPECT_FP_EQ(-0.0, func(0.0, -0.0));
-    EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+    EXPECT_FP_EQ(zero, func(zero, zero));
+    EXPECT_FP_EQ(neg_zero, func(neg_zero, zero));
+    EXPECT_FP_EQ(neg_zero, func(zero, neg_zero));
+    EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
   }
 
   void testRange(FMinFunc func) {
diff --git a/libc/test/src/math/FrexpTest.h b/libc/test/src/math/FrexpTest.h
index 74a2d607b0f9f..d1151c83efbd3 100644
--- a/libc/test/src/math/FrexpTest.h
+++ b/libc/test/src/math/FrexpTest.h
@@ -33,10 +33,10 @@ class FrexpTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     ASSERT_FP_EQ(inf, func(inf, &exponent));
     ASSERT_FP_EQ(neg_inf, func(neg_inf, &exponent));
 
-    ASSERT_FP_EQ(0.0, func(0.0, &exponent));
+    ASSERT_FP_EQ(zero, func(zero, &exponent));
     ASSERT_EQ(exponent, 0);
 
-    ASSERT_FP_EQ(-0.0, func(-0.0, &exponent));
+    ASSERT_FP_EQ(neg_zero, func(neg_zero, &exponent));
     ASSERT_EQ(exponent, 0);
   }
 
diff --git a/libc/test/src/math/NextAfterTest.h b/libc/test/src/math/NextAfterTest.h
index d97c264cbd806..82d5378ec3533 100644
--- a/libc/test/src/math/NextAfterTest.h
+++ b/libc/test/src/math/NextAfterTest.h
@@ -100,7 +100,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     expected_bits = min_subnormal + 1;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
-    ASSERT_FP_EQ(func(x, 0), 0);
+    ASSERT_FP_EQ(func(x, 0), zero);
 
     x = -x;
     result = func(x, -1);
diff --git a/libc/test/src/math/exhaustive/exhaustive_test.h b/libc/test/src/math/exhaustive/exhaustive_test.h
index 5912f7a27dc52..cdf459c23bb9d 100644
--- a/libc/test/src/math/exhaustive/exhaustive_test.h
+++ b/libc/test/src/math/exhaustive/exhaustive_test.h
@@ -169,7 +169,8 @@ struct LlvmLibcExhaustiveMathTest
               range_end = stop;
             }
             current_value = range_end;
-            int pc = 100.0 * (range_end - start) / (stop - start);
+            int pc =
+                static_cast<int>(100.0 * (range_end - start) / (stop - start));
             if (current_percent != pc) {
               new_percent = pc;
               current_percent = pc;
diff --git a/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp b/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp
index b064b7e37f428..fc3156d8c69c0 100644
--- a/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp
+++ b/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp
@@ -48,13 +48,13 @@ class LlvmLibcFModTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     int max2 = 3 + FPBits::MAX_BIASED_EXPONENT / 2;
     for (T by : TEST_BASES) {
       for (int iy = min2; iy < max2; iy++) {
-        T y = by * LIBC_NAMESPACE::fputil::ldexp(2.0, iy);
+        T y = by * LIBC_NAMESPACE::fputil::ldexp(T(2.0), iy);
         FPBits y_bits(y);
         if (y_bits.is_zero() || !y_bits.is_finite())
           continue;
         for (T bx : TEST_BASES) {
           for (int ix = min2; ix < max2; ix++) {
-            T x = bx * LIBC_NAMESPACE::fputil::ldexp(2.0, ix);
+            T x = bx * LIBC_NAMESPACE::fputil::ldexp(T(2.0), ix);
             if (!FPBits(x).is_finite())
               continue;
             T result = FMod::eval(x, y);
diff --git a/libc/test/src/math/smoke/NextAfterTest.h b/libc/test/src/math/smoke/NextAfterTest.h
index e62832e6712f3..be27c9f188a72 100644
--- a/libc/test/src/math/smoke/NextAfterTest.h
+++ b/libc/test/src/math/smoke/NextAfterTest.h
@@ -115,7 +115,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     expected_bits = min_subnormal + 1;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ_WITH_UNDERFLOW(result, expected);
-    ASSERT_FP_EQ_WITH_UNDERFLOW(func(x, 0), 0);
+    ASSERT_FP_EQ_WITH_UNDERFLOW(func(x, 0), zero);
 
     x = -x;
     result = func(x, -1);
diff --git a/libc/test/src/math/smoke/NextTowardTest.h b/libc/test/src/math/smoke/NextTowardTest.h
index a4cd5d0cc8c8f..d2f352cdcbdf7 100644
--- a/libc/test/src/math/smoke/NextTowardTest.h
+++ b/libc/test/src/math/smoke/NextTowardTest.h
@@ -122,7 +122,7 @@ class NextTowardTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     expected_bits = min_subnormal + 1;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ_WITH_UNDERFLOW(result, expected);
-    ASSERT_FP_EQ_WITH_UNDERFLOW(func(x, 0), 0);
+    ASSERT_FP_EQ_WITH_UNDERFLOW(func(x, 0), zero);
 
     x = -x;
     result = func(x, -1);
diff --git a/libc/test/src/stdio/fileop_test.cpp b/libc/test/src/stdio/fileop_test.cpp
index c662a9fbd0860..a0368d701a676 100644
--- a/libc/test/src/stdio/fileop_test.cpp
+++ b/libc/test/src/stdio/fileop_test.cpp
@@ -87,7 +87,7 @@ TEST(LlvmLibcFILETest, SimpleFileOperations) {
 
   LIBC_NAMESPACE::libc_errno = 0;
   ASSERT_THAT(LIBC_NAMESPACE::fwrite("nothing", 1, 1, file),
-              returns(EQ(0)).with_errno(NE(0)));
+              returns(EQ(size_t(0))).with_errno(NE(0)));
   LIBC_NAMESPACE::libc_errno = 0;
 
   ASSERT_EQ(LIBC_NAMESPACE::fclose(file), 0);
diff --git a/libc/test/src/stdio/sscanf_test.cpp b/libc/test/src/stdio/sscanf_test.cpp
index 18addb632067c..cb302df5b3d82 100644
--- a/libc/test/src/stdio/sscanf_test.cpp
+++ b/libc/test/src/stdio/sscanf_test.cpp
@@ -246,27 +246,27 @@ TEST(LlvmLibcSScanfTest, FloatConvSimple) {
 
   ret_val = LIBC_NAMESPACE::sscanf("123", "%f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 123.0);
+  EXPECT_FP_EQ(result, 123.0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("456.1", "%a", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 456.1);
+  EXPECT_FP_EQ(result, 456.1f);
 
   ret_val = LIBC_NAMESPACE::sscanf("0x789.ap0", "%e", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 0x789.ap0);
+  EXPECT_FP_EQ(result, 0x789.ap0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("0x.8", "%e", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 0x0.8p0);
+  EXPECT_FP_EQ(result, 0x0.8p0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("0x8.", "%e", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 0x8.0p0);
+  EXPECT_FP_EQ(result, 0x8.0p0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("+12.0e1", "%g", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 12.0e1);
+  EXPECT_FP_EQ(result, 12.0e1f);
 
   ret_val = LIBC_NAMESPACE::sscanf("inf", "%F", &result);
   EXPECT_EQ(ret_val, 1);
@@ -282,19 +282,19 @@ TEST(LlvmLibcSScanfTest, FloatConvSimple) {
 
   ret_val = LIBC_NAMESPACE::sscanf("1e10", "%G", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 1e10);
+  EXPECT_FP_EQ(result, 1e10f);
 
   ret_val = LIBC_NAMESPACE::sscanf(".1", "%G", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 0.1);
+  EXPECT_FP_EQ(result, 0.1f);
 
   ret_val = LIBC_NAMESPACE::sscanf("1.", "%G", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 1.0);
+  EXPECT_FP_EQ(result, 1.0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("0", "%f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 0.0);
+  EXPECT_FP_EQ(result, 0.0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("Not a float", "%f", &result);
   EXPECT_EQ(ret_val, 0);
@@ -407,7 +407,7 @@ TEST(LlvmLibcSScanfTest, FloatConvComplexParsing) {
 
   ret_val = LIBC_NAMESPACE::sscanf("0x1.0e3", "%f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 0x1.0e3p0);
+  EXPECT_FP_EQ(result, 0x1.0e3p0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("", "%a", &result);
   EXPECT_EQ(ret_val, 0);
@@ -463,11 +463,11 @@ TEST(LlvmLibcSScanfTest, FloatConvComplexParsing) {
 
   ret_val = LIBC_NAMESPACE::sscanf("-.1e1", "%f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, -.1e1);
+  EXPECT_FP_EQ(result, -.1e1f);
 
   ret_val = LIBC_NAMESPACE::sscanf("1.2.e1", "%f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 1.2);
+  EXPECT_FP_EQ(result, 1.2f);
 }
 
 TEST(LlvmLibcSScanfTest, FloatConvMaxWidth) {
@@ -478,22 +478,22 @@ TEST(LlvmLibcSScanfTest, FloatConvMaxWidth) {
 
   ret_val = LIBC_NAMESPACE::sscanf("123", "%3f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 123.0);
+  EXPECT_FP_EQ(result, 123.0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("123", "%5f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 123.0);
+  EXPECT_FP_EQ(result, 123.0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("456", "%1f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 4.0);
+  EXPECT_FP_EQ(result, 4.0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("-789", "%1f", &result);
   EXPECT_EQ(ret_val, 0);
 
   ret_val = LIBC_NAMESPACE::sscanf("-123", "%2f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, -1.0);
+  EXPECT_FP_EQ(result, -1.0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("inf", "%2f", &result);
   EXPECT_EQ(ret_val, 0);
@@ -519,11 +519,11 @@ TEST(LlvmLibcSScanfTest, FloatConvMaxWidth) {
 
   ret_val = LIBC_NAMESPACE::sscanf("01", "%1f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 0.0);
+  EXPECT_FP_EQ(result, 0.0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("0x1", "%2f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 0.0);
+  EXPECT_FP_EQ(result, 0.0f);
 
   ret_val = LIBC_NAMESPACE::sscanf("100e", "%4f", &result);
   EXPECT_EQ(ret_val, 0);
@@ -533,7 +533,7 @@ TEST(LlvmLibcSScanfTest, FloatConvMaxWidth) {
 
   ret_val = LIBC_NAMESPACE::sscanf("100e10", "%5f", &result);
   EXPECT_EQ(ret_val, 1);
-  EXPECT_FP_EQ(result, 100e1);...
[truncated]

@lntue lntue merged commit d0a0de5 into llvm:main Mar 14, 2025
13 of 15 checks passed
@lntue lntue deleted the warnings branch March 14, 2025 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants