-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libc] Fix some warnings in tests. #150500
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-libc Author: None (lntue) ChangesFull diff: https://github.com/llvm/llvm-project/pull/150500.diff 7 Files Affected:
diff --git a/libc/src/__support/FPUtil/generic/add_sub.h b/libc/src/__support/FPUtil/generic/add_sub.h
index fda702931ef6f..7205d8d41f5bd 100644
--- a/libc/src/__support/FPUtil/generic/add_sub.h
+++ b/libc/src/__support/FPUtil/generic/add_sub.h
@@ -153,8 +153,10 @@ add_or_sub(InType x, InType y) {
result_mant <<= GUARD_BITS_LEN;
} else {
- InStorageType max_mant = max_bits.get_explicit_mantissa() << GUARD_BITS_LEN;
- InStorageType min_mant = min_bits.get_explicit_mantissa() << GUARD_BITS_LEN;
+ InStorageType max_mant = static_cast<InStorageType>(
+ max_bits.get_explicit_mantissa() << GUARD_BITS_LEN);
+ InStorageType min_mant = static_cast<InStorageType>(
+ min_bits.get_explicit_mantissa() << GUARD_BITS_LEN);
int alignment = (max_bits.get_biased_exponent() - max_bits.is_normal()) -
(min_bits.get_biased_exponent() - min_bits.is_normal());
@@ -172,7 +174,8 @@ add_or_sub(InType x, InType y) {
(static_cast<InStorageType>(
min_mant << (InFPBits::STORAGE_LEN - alignment))) != 0;
- InStorageType min_mant_sticky(static_cast<int>(aligned_min_mant_sticky));
+ InStorageType min_mant_sticky =
+ static_cast<InStorageType>(static_cast<int>(aligned_min_mant_sticky));
if (is_effectively_add)
result_mant = max_mant + (aligned_min_mant | min_mant_sticky);
diff --git a/libc/test/src/math/FmaTest.h b/libc/test/src/math/FmaTest.h
index 5c5419ce3ab4d..902ff0413b0fa 100644
--- a/libc/test/src/math/FmaTest.h
+++ b/libc/test/src/math/FmaTest.h
@@ -48,7 +48,8 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
InStorageType get_random_bit_pattern() {
InStorageType bits{0};
for (InStorageType i = 0; i < sizeof(InStorageType) / 2; ++i) {
- bits = (bits << 2) + static_cast<uint16_t>(LIBC_NAMESPACE::rand());
+ bits = static_cast<InStorageType>(
+ (bits << 2) + static_cast<uint16_t>(LIBC_NAMESPACE::rand()));
}
return bits;
}
@@ -57,7 +58,7 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
using FmaFunc = OutType (*)(InType, InType, InType);
void test_subnormal_range(FmaFunc func) {
- constexpr InStorageType COUNT = 100'001;
+ constexpr InStorageType COUNT = 10'001;
constexpr InStorageType RAW_STEP =
(IN_MAX_SUBNORMAL_U - IN_MIN_SUBNORMAL_U) / COUNT;
constexpr InStorageType STEP = (RAW_STEP == 0 ? 1 : RAW_STEP);
@@ -75,7 +76,7 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
}
void test_normal_range(FmaFunc func) {
- constexpr InStorageType COUNT = 100'001;
+ constexpr InStorageType COUNT = 10'001;
constexpr InStorageType RAW_STEP =
(IN_MAX_NORMAL_U - IN_MIN_NORMAL_U) / COUNT;
constexpr InStorageType STEP = (RAW_STEP == 0 ? 1 : RAW_STEP);
diff --git a/libc/test/src/math/HypotTest.h b/libc/test/src/math/HypotTest.h
index dc73581e67ff0..b37abf7e156d3 100644
--- a/libc/test/src/math/HypotTest.h
+++ b/libc/test/src/math/HypotTest.h
@@ -71,8 +71,9 @@ class HypotTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void test_subnormal_range(Func func) {
constexpr StorageType COUNT = 10'001;
- for (unsigned scale = 0; scale < 4; ++scale) {
- StorageType max_value = MAX_SUBNORMAL << scale;
+ constexpr unsigned SCALE = (sizeof(T) < 4) ? 1 : 4;
+ for (unsigned scale = 0; scale < SCALE; ++scale) {
+ StorageType max_value = static_cast<StorageType>(MAX_SUBNORMAL << scale);
StorageType step = (max_value - MIN_SUBNORMAL) / COUNT + 1;
for (int signs = 0; signs < 4; ++signs) {
for (StorageType v = MIN_SUBNORMAL, w = max_value;
diff --git a/libc/test/src/wchar/wcstol_test.cpp b/libc/test/src/wchar/wcstol_test.cpp
index 9ae32ba5183e6..2dd0bc7e2b0c6 100644
--- a/libc/test/src/wchar/wcstol_test.cpp
+++ b/libc/test/src/wchar/wcstol_test.cpp
@@ -12,4 +12,4 @@
#include "WcstolTest.h"
-WCSTOL_TEST(Wcstol, LIBC_NAMESPACE::wcstol)
\ No newline at end of file
+WCSTOL_TEST(Wcstol, LIBC_NAMESPACE::wcstol)
diff --git a/libc/test/src/wchar/wcstoll_test.cpp b/libc/test/src/wchar/wcstoll_test.cpp
index c24c1f69b1cec..00a241aa88f20 100644
--- a/libc/test/src/wchar/wcstoll_test.cpp
+++ b/libc/test/src/wchar/wcstoll_test.cpp
@@ -12,4 +12,4 @@
#include "WcstolTest.h"
-WCSTOL_TEST(Wcstoll, LIBC_NAMESPACE::wcstoll)
\ No newline at end of file
+WCSTOL_TEST(Wcstoll, LIBC_NAMESPACE::wcstoll)
diff --git a/libc/test/src/wchar/wcstoul_test.cpp b/libc/test/src/wchar/wcstoul_test.cpp
index ab0afb951c495..63b630daa9f13 100644
--- a/libc/test/src/wchar/wcstoul_test.cpp
+++ b/libc/test/src/wchar/wcstoul_test.cpp
@@ -12,4 +12,4 @@
#include "WcstolTest.h"
-WCSTOL_TEST(Wcstoul, LIBC_NAMESPACE::wcstoul)
\ No newline at end of file
+WCSTOL_TEST(Wcstoul, LIBC_NAMESPACE::wcstoul)
diff --git a/libc/test/src/wchar/wcstoull_test.cpp b/libc/test/src/wchar/wcstoull_test.cpp
index adba4f16e68d6..12895d3ed4148 100644
--- a/libc/test/src/wchar/wcstoull_test.cpp
+++ b/libc/test/src/wchar/wcstoull_test.cpp
@@ -12,4 +12,4 @@
#include "WcstolTest.h"
-WCSTOL_TEST(Wcstoull, LIBC_NAMESPACE::wcstoull)
\ No newline at end of file
+WCSTOL_TEST(Wcstoull, LIBC_NAMESPACE::wcstoull)
|
jhuber6
approved these changes
Jul 24, 2025
SchrodingerZhu
approved these changes
Jul 24, 2025
mahesh-attarde
pushed a commit
to mahesh-attarde/llvm-project
that referenced
this pull request
Jul 28, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.