[libc] Fix warnings for the GPU test suite (#181763)

Summary:
A lot of fixes mostly around unused variables.
This commit is contained in:
Joseph Huber
2026-02-17 09:30:36 -06:00
committed by GitHub
parent 897173ec7d
commit e50bed6da4
15 changed files with 23 additions and 19 deletions

View File

@@ -115,7 +115,8 @@ void FEnvSafeTest::expect_fenv_eq(const fenv_t &before_fenv,
#else
// No arch-specific `fenv_t` support, so nothing to compare.
(void)before_fenv;
(void)after_fenv;
#endif
}

View File

@@ -27,7 +27,7 @@ TEST(LlvmLibcComplexTest, CMPLXMacro) {
EXPECT_CFP_EQ(CMPLXL(1.0l, 0), 1.0l);
#ifdef LIBC_TYPES_HAS_CFLOAT16
EXPECT_CFP_EQ(CMPLXF16(0, 1.0), I);
EXPECT_CFP_EQ(CMPLXF16(0, 1.0), CMPLXF16(__real__ I, __imag__ I));
EXPECT_CFP_EQ(CMPLXF16(1.0, 0), 1.0);
#endif // LIBC_TYPES_HAS_CFLOAT16

View File

@@ -37,7 +37,7 @@ void run() {
;
}
TEST_MAIN(int argc, char **argv, char **envp) {
TEST_MAIN(int, char **, char **) {
run();
return 0;

View File

@@ -30,7 +30,7 @@ static void test_match() {
#endif
}
TEST_MAIN(int argc, char **argv, char **envp) {
TEST_MAIN(int, char **, char **) {
if (gpu::get_thread_id() >= gpu::get_lane_size())
return 0;

View File

@@ -97,7 +97,7 @@ static void test_scan_divergent() {
}
}
TEST_MAIN(int argc, char **argv, char **envp) {
TEST_MAIN(int, char **, char **) {
if (gpu::get_thread_id() >= gpu::get_lane_size())
return 0;

View File

@@ -16,14 +16,14 @@ using namespace LIBC_NAMESPACE;
// Each iteration reduces the width, so it will broadcast to a subset we check.
static void test_shuffle() {
uint64_t mask = gpu::get_lane_mask();
EXPECT_EQ(cpp::popcount(mask), gpu::get_lane_size());
EXPECT_EQ(static_cast<uint32_t>(cpp::popcount(mask)), gpu::get_lane_size());
uint32_t x = gpu::get_lane_id();
for (uint32_t width = gpu::get_lane_size(); width > 0; width /= 2)
EXPECT_EQ(gpu::shuffle(mask, 0, x, width), (x / width) * width);
}
TEST_MAIN(int argc, char **argv, char **envp) {
TEST_MAIN(int, char **, char **) {
if (gpu::get_thread_id() >= gpu::get_lane_size())
return 0;

View File

@@ -16,7 +16,7 @@ using namespace LIBC_NAMESPACE;
FILE *file = LIBC_NAMESPACE::fopen("testdata/test_data.txt", "w");
TEST_MAIN(int argc, char **argv, char **envp) {
TEST_MAIN(int, char **, char **) {
ASSERT_TRUE(file && "failed to open file");
// Check basic printing.
int written = 0;

View File

@@ -30,11 +30,11 @@ static inline uint32_t xorshift32(uint32_t &state) {
static inline void use(uint8_t *ptr, uint32_t size) {
EXPECT_NE(ptr, nullptr);
for (int i = 0; i < size; ++i)
for (uint32_t i = 0; i < size; ++i)
ptr[i] = uint8_t(i + gpu::get_thread_id());
// Try to detect if some other thread manages to clobber our memory.
for (int i = 0; i < size; ++i)
for (uint32_t i = 0; i < size; ++i)
EXPECT_EQ(ptr[i], uint8_t(i + gpu::get_thread_id()));
}

View File

@@ -53,7 +53,7 @@ __attribute__((destructor(101))) void reset_initval() {
initval = 0;
}
TEST_MAIN(int argc, char **argv, char **env) {
TEST_MAIN(int, char **, char **) {
ASSERT_EQ(global.get(GLOBAL_INDEX), INITVAL_INITIALIZER);
ASSERT_EQ(initval, INITVAL_INITIALIZER);
return 0;

View File

@@ -57,7 +57,7 @@ static void test_interface(bool end_with_send) {
ASSERT_TRUE(cnt == 9 && "Invalid number of increments");
}
TEST_MAIN(int argc, char **argv, char **envp) {
TEST_MAIN(int, char **, char **) {
test_interface(true);
test_interface(false);

View File

@@ -39,7 +39,7 @@ static void test_noop(uint8_t data) {
});
}
TEST_MAIN(int argc, char **argv, char **envp) {
TEST_MAIN(int, char **, char **) {
test_add_simple();
if (gpu::get_thread_id() % 2)

View File

@@ -15,7 +15,7 @@
#include "test/UnitTest/Test.h"
TEST(LlvmLibcFOpenTest, PrintToFile) {
int result;
size_t result;
FILE *file =
LIBC_NAMESPACE::fopen(APPEND_LIBC_TEST("testdata/test.txt"), "w");
@@ -23,7 +23,7 @@ TEST(LlvmLibcFOpenTest, PrintToFile) {
static constexpr char STRING[] = "A simple string written to a file\n";
result = LIBC_NAMESPACE::fwrite(STRING, 1, sizeof(STRING) - 1, file);
EXPECT_GE(result, 0);
EXPECT_GE(result, size_t(0));
ASSERT_EQ(0, LIBC_NAMESPACE::fclose(file));

View File

@@ -23,7 +23,8 @@ class LlvmLibcStrToFTest : public LIBC_NAMESPACE::testing::ErrnoCheckingTest,
ForceRoundingModeTest<RoundingMode::Nearest> {
public:
void run_test(const char *inputString, const ptrdiff_t expectedStrLen,
const uint32_t expectedRawData, const int expectedErrno = 0) {
const uint32_t expectedRawData,
[[maybe_unused]] const int expectedErrno = 0) {
// expectedRawData is the expected float result as a uint32_t, organized
// according to IEEE754:
//

View File

@@ -78,7 +78,7 @@ public:
using FPBits = LIBC_NAMESPACE::fputil::FPBits<long double>;
FPBits expected_fp =
FPBits(static_cast<FPBits::StorageType>(expectedRawData));
const int expected_errno = expectedErrno;
[[maybe_unused]] const int expected_errno = expectedErrno;
long double result = LIBC_NAMESPACE::strtold(inputString, &str_end);

View File

@@ -36,7 +36,8 @@ TEST(LlvmLibcMkTime, FailureSetsErrno) {
.tm_wday = 0,
.tm_yday = 0,
.tm_isdst = 0};
EXPECT_THAT(LIBC_NAMESPACE::mktime(&tm_data), Fails(EOVERFLOW));
EXPECT_THAT(static_cast<int>(LIBC_NAMESPACE::mktime(&tm_data)),
Fails(EOVERFLOW));
}
TEST(LlvmLibcMkTime, InvalidSeconds) {
@@ -51,7 +52,8 @@ TEST(LlvmLibcMkTime, InvalidSeconds) {
.tm_wday = 0,
.tm_yday = 0,
.tm_isdst = 0};
EXPECT_THAT(LIBC_NAMESPACE::mktime(&tm_data), Succeeds(-1));
EXPECT_THAT(static_cast<int>(LIBC_NAMESPACE::mktime(&tm_data)),
Succeeds(-1));
EXPECT_TM_EQ((tm{.tm_sec = 59,
.tm_min = 59,
.tm_hour = 23,