Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libc/cmake/modules/LLVMLibCTestRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion libc/test/UnitTest/FPExceptMatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace testing {
static thread_local sigjmp_buf jumpBuffer;
static thread_local bool caughtExcept;

static void sigfpeHandler([[maybe_unused]] int sig) {
static void sigfpeHandler(int sig) {
caughtExcept = true;
siglongjmp(jumpBuffer, -1);
}
Expand Down
2 changes: 1 addition & 1 deletion libc/test/UnitTest/FPExceptMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FPExceptMatcher : public Matcher<bool> {
// Takes ownership of func.
explicit FPExceptMatcher(FunctionCaller *func);

bool match([[maybe_unused]] bool unused) { return exceptionRaised; }
bool match(bool unused) { return exceptionRaised; }

void explainError() override {
tlog << "A floating point exception should have been raised but it "
Expand Down
17 changes: 5 additions & 12 deletions libc/test/UnitTest/HermeticTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ 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([[maybe_unused]] unsigned long id) {
return 0;
}
[[gnu::weak]] unsigned long getauxval(unsigned long id) { return 0; }

} // namespace LIBC_NAMESPACE_DECL

Expand Down Expand Up @@ -126,7 +124,7 @@ unsigned long __getauxval(unsigned long id) {

} // extern "C"

void *operator new([[maybe_unused]] size_t size, void *ptr) { return ptr; }
void *operator new(size_t size, void *ptr) { return ptr; }

void *operator new(size_t size) { return malloc(size); }

Expand All @@ -138,9 +136,7 @@ void operator delete(void *) {
__builtin_trap();
}

void operator delete([[maybe_unused]] void *ptr, [[maybe_unused]] size_t size) {
__builtin_trap();
}
void operator delete(void *ptr, 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
Expand All @@ -149,11 +145,8 @@ namespace std {
enum class align_val_t : size_t {};
} // namespace std

void operator delete([[maybe_unused]] void *mem, std::align_val_t) noexcept {
__builtin_trap();
}
void operator delete(void *mem, std::align_val_t) noexcept { __builtin_trap(); }

void operator delete([[maybe_unused]] void *mem, unsigned int,
std::align_val_t) noexcept {
void operator delete(void *mem, unsigned int, std::align_val_t) noexcept {
__builtin_trap();
}
3 changes: 1 addition & 2 deletions libc/test/UnitTest/LibcDeathTestExecutors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace testing {

bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
const char *LHSStr,
[[maybe_unused]] const char *RHSStr,
const char *LHSStr, const char *RHSStr,
internal::Location Loc) {
testutils::ProcessStatus Result =
testutils::invoke_in_subprocess(Func, TIMEOUT_MS);
Expand Down
2 changes: 1 addition & 1 deletion libc/test/UnitTest/LibcTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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=([[maybe_unused]] Message msg) {}
void operator=(Message msg) {}
};

struct RunContext {
Expand Down
70 changes: 21 additions & 49 deletions libc/test/include/stdbit_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,11 @@
#include <stdbool.h> // bool in C

#define STDBIT_STUB_FUNCTION(FUNC_NAME, LEADING_VAL) \
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; \
}
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; }

__BEGIN_C_DECLS

Expand All @@ -46,42 +36,24 @@ 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([[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;
}
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; }

STDBIT_STUB_FUNCTION(stdc_bit_width, 0x4)

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;
}
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; }

__END_C_DECLS
4 changes: 2 additions & 2 deletions libc/test/integration/src/pthread/pthread_mutex_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ constexpr int MAX = 10000;
pthread_mutex_t mutex;
static int shared_int = START;

void *counter([[maybe_unused]] void *arg) {
void *counter(void *arg) {
int last_count = START;
while (true) {
LIBC_NAMESPACE::pthread_mutex_lock(&mutex);
Expand Down Expand Up @@ -72,7 +72,7 @@ void relay_counter() {
pthread_mutex_t start_lock, step_lock;
bool started, step;

void *stepper([[maybe_unused]] void *arg) {
void *stepper(void *arg) {
LIBC_NAMESPACE::pthread_mutex_lock(&start_lock);
started = true;
LIBC_NAMESPACE::pthread_mutex_unlock(&start_lock);
Expand Down
3 changes: 1 addition & 2 deletions libc/test/integration/src/spawn/posix_spawn_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ void spawn_and_wait_for_normal_exit(char **envp) {
ASSERT_EQ(exit_status, 0);
}

TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
char **envp) {
TEST_MAIN(int argc, char **argv, char **envp) {
spawn_and_wait_for_normal_exit(envp);
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <string.h>
#include <unistd.h>

int main(int argc, [[maybe_unused]] char **argv) {
int main(int argc, char **argv) {
if (argc != 1)
return 5;
constexpr size_t bufsize = sizeof(TEXT);
Expand Down
2 changes: 1 addition & 1 deletion libc/test/integration/src/stdio/sprintf_size_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int my_strlen(const char *str) {
return static_cast<int>(other - str);
}

TEST_MAIN(int argc, char **argv, [[maybe_unused]] char **envp) {
TEST_MAIN(int argc, char **argv, char **envp) {
ASSERT_EQ(argc, 5);
ASSERT_TRUE(my_streq(argv[1], "%s %c %d"));
ASSERT_EQ(my_strlen(argv[1]), 8);
Expand Down
3 changes: 1 addition & 2 deletions libc/test/integration/src/stdlib/getenv_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ static bool my_streq(const char *lhs, const char *rhs) {
return *l == '\0' && *r == '\0';
}

TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
[[maybe_unused]] char **envp) {
TEST_MAIN(int argc, char **argv, char **envp) {
ASSERT_TRUE(
my_streq(LIBC_NAMESPACE::getenv(""), static_cast<char *>(nullptr)));
ASSERT_TRUE(
Expand Down
2 changes: 1 addition & 1 deletion libc/test/integration/src/threads/cnd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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([[maybe_unused]] void *unused) {
int waiter_thread_func(void *unused) {
LIBC_NAMESPACE::mtx_lock(&waiter_mtx);

LIBC_NAMESPACE::mtx_lock(&main_thread_mtx);
Expand Down
4 changes: 2 additions & 2 deletions libc/test/integration/src/threads/mtx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ constexpr int MAX = 10000;
mtx_t mutex;
static int shared_int = START;

int counter([[maybe_unused]] void *arg) {
int counter(void *arg) {
int last_count = START;
while (true) {
LIBC_NAMESPACE::mtx_lock(&mutex);
Expand Down Expand Up @@ -74,7 +74,7 @@ void relay_counter() {
mtx_t start_lock, step_lock;
bool started, step;

int stepper([[maybe_unused]] void *arg) {
int stepper(void *arg) {
LIBC_NAMESPACE::mtx_lock(&start_lock);
started = true;
LIBC_NAMESPACE::mtx_unlock(&start_lock);
Expand Down
3 changes: 1 addition & 2 deletions libc/test/integration/src/unistd/execv_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ void fork_and_execv_signal_exit() {
ASSERT_TRUE(WTERMSIG(status) == SIGUSR1);
}

TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
[[maybe_unused]] char **envp) {
TEST_MAIN(int argc, char **argv, char **envp) {
fork_and_execv_normal_exit();
fork_and_execv_signal_exit();
return 0;
Expand Down
3 changes: 1 addition & 2 deletions libc/test/integration/src/unistd/execve_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ void fork_and_execv_signal_exit(char **envp) {
ASSERT_TRUE(WTERMSIG(status) == SIGUSR1);
}

TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
char **envp) {
TEST_MAIN(int argc, char **argv, char **envp) {
fork_and_execv_normal_exit(envp);
fork_and_execv_signal_exit(envp);
return 0;
Expand Down
3 changes: 1 addition & 2 deletions libc/test/integration/src/unistd/fork_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ void gettid_test() {
ASSERT_EQ(WEXITSTATUS(status), 0);
}

TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
[[maybe_unused]] char **envp) {
TEST_MAIN(int argc, char **argv, char **envp) {
gettid_test();
fork_and_wait_normal_exit();
fork_and_wait4_normal_exit();
Expand Down
3 changes: 1 addition & 2 deletions libc/test/integration/src/unistd/getcwd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

using LIBC_NAMESPACE::cpp::string_view;

TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
[[maybe_unused]] char **envp) {
TEST_MAIN(int argc, char **argv, char **envp) {
char buffer[1024];
ASSERT_TRUE(string_view(LIBC_NAMESPACE::getenv("PWD")) ==
LIBC_NAMESPACE::getcwd(buffer, 1024));
Expand Down
2 changes: 1 addition & 1 deletion libc/test/integration/startup/linux/main_without_envp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

#include "test/IntegrationTest/test.h"

TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv) { return 0; }
TEST_MAIN(int argc, char **argv) { return 0; }
3 changes: 1 addition & 2 deletions libc/test/integration/startup/linux/tls_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
constexpr int threadLocalDataSize = 101;
_Thread_local int a[threadLocalDataSize] = {123};

TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
[[maybe_unused]] char **envp) {
TEST_MAIN(int argc, char **argv, char **envp) {
ASSERT_TRUE(a[0] == 123);

for (int i = 1; i < threadLocalDataSize; ++i)
Expand Down
3 changes: 1 addition & 2 deletions libc/test/src/__support/CPP/integer_sequence_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ TEST(LlvmLibcIntegerSequencetTest, Basic) {
(is_same_v<ULLSeq, make_integer_sequence<unsigned long long, 4>>));
}

template <typename T, T... Ts>
bool checkArray([[maybe_unused]] integer_sequence<T, Ts...> seq) {
template <typename T, T... Ts> bool checkArray(integer_sequence<T, Ts...> seq) {
T arr[sizeof...(Ts)]{Ts...};

for (T i = 0; i < static_cast<T>(sizeof...(Ts)); i++)
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/__support/freelist_heap_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ using LIBC_NAMESPACE::cpp::span;
RunTest(*freelist_heap, freelist_heap->region().size()); \
} \
void LlvmLibcFreeListHeapTest##TestCase::RunTest(FreeListHeap &allocator, \
[[maybe_unused]] size_t N)
size_t N)

TEST_FOR_EACH_ALLOCATOR(CanAllocate, 2048) {
constexpr size_t ALLOC_SIZE = 512;
Expand Down
5 changes: 2 additions & 3 deletions libc/test/src/math/exhaustive/hypotf16_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ 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,
[[maybe_unused]] uint16_t y_start, uint16_t y_stop,
mpfr::RoundingMode rounding) {
uint64_t check(uint16_t x_start, uint16_t x_stop, uint16_t y_start,
uint16_t y_stop, mpfr::RoundingMode rounding) {
mpfr::ForceRoundingMode r(rounding);
if (!r.success)
return true;
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/stdlib/StrfromTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class StrfromTest : public LIBC_NAMESPACE::testing::Test {
ASSERT_STREQ_LEN(written, buff, "1.0e+01");
}

void floatDecimalExpLongDoublePrec([[maybe_unused]] FunctionT func) {
void floatDecimalExpLongDoublePrec(FunctionT func) {
// Mark as maybe_unused to silence unused variable
// warning when long double is not 80-bit
[[maybe_unused]] char buff[100];
Expand Down Expand Up @@ -422,7 +422,7 @@ class StrfromTest : public LIBC_NAMESPACE::testing::Test {
ASSERT_STREQ_LEN(written, buff, "1.2340000000000000814e-10");
}

void floatDecimalAutoLongDoublePrec([[maybe_unused]] FunctionT func) {
void floatDecimalAutoLongDoublePrec(FunctionT func) {
// Mark as maybe_unused to silence unused variable
// warning when long double is not 80-bit
[[maybe_unused]] char buff[100];
Expand Down
9 changes: 3 additions & 6 deletions libc/test/src/string/memory_utils/op_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ 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,
[[maybe_unused]] size_t size) {
void CopyBlockAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {
FnImpl(as_byte(dst), as_byte(src));
}

Expand Down Expand Up @@ -154,8 +153,7 @@ 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,
[[maybe_unused]] size_t size) {
void SetBlockAdaptor(cpp::span<char> dst, uint8_t value, size_t size) {
FnImpl(as_byte(dst), value);
}

Expand Down Expand Up @@ -244,8 +242,7 @@ 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,
[[maybe_unused]] size_t size) {
int CmpBlockAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {
return (int)FnImpl(as_byte(p1), as_byte(p2));
}

Expand Down
Loading
Loading