Skip to content

Commit 33fe635

Browse files
authored
Revert "[libc] Add -Wextra for libc tests" (#153169)
Reverts #133643
1 parent 598f21e commit 33fe635

27 files changed

+58
-108
lines changed

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function(_get_common_test_compile_options output_var c_test flags)
4040
endif()
4141

4242
# list(APPEND compile_options "-Wall")
43-
list(APPEND compile_options "-Wextra")
43+
# list(APPEND compile_options "-Wextra")
4444
# -DLIBC_WNO_ERROR=ON if you can't build cleanly with -Werror.
4545
if(NOT LIBC_WNO_ERROR)
4646
# list(APPEND compile_options "-Werror")

libc/test/UnitTest/FPExceptMatcher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace testing {
3131
static thread_local sigjmp_buf jumpBuffer;
3232
static thread_local bool caughtExcept;
3333

34-
static void sigfpeHandler([[maybe_unused]] int sig) {
34+
static void sigfpeHandler(int sig) {
3535
caughtExcept = true;
3636
siglongjmp(jumpBuffer, -1);
3737
}

libc/test/UnitTest/FPExceptMatcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class FPExceptMatcher : public Matcher<bool> {
4343
// Takes ownership of func.
4444
explicit FPExceptMatcher(FunctionCaller *func);
4545

46-
bool match([[maybe_unused]] bool unused) { return exceptionRaised; }
46+
bool match(bool unused) { return exceptionRaised; }
4747

4848
void explainError() override {
4949
tlog << "A floating point exception should have been raised but it "

libc/test/UnitTest/HermeticTestUtils.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ int atexit(void (*func)(void));
2929
// add_libc_hermetic_test properly. Such that they won't get correct linkage
3030
// against the object containing this function. We create a dummy function that
3131
// always returns 0 to indicate a failure.
32-
[[gnu::weak]] unsigned long getauxval([[maybe_unused]] unsigned long id) {
33-
return 0;
34-
}
32+
[[gnu::weak]] unsigned long getauxval(unsigned long id) { return 0; }
3533

3634
} // namespace LIBC_NAMESPACE_DECL
3735

@@ -126,7 +124,7 @@ unsigned long __getauxval(unsigned long id) {
126124

127125
} // extern "C"
128126

129-
void *operator new([[maybe_unused]] size_t size, void *ptr) { return ptr; }
127+
void *operator new(size_t size, void *ptr) { return ptr; }
130128

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

@@ -138,9 +136,7 @@ void operator delete(void *) {
138136
__builtin_trap();
139137
}
140138

141-
void operator delete([[maybe_unused]] void *ptr, [[maybe_unused]] size_t size) {
142-
__builtin_trap();
143-
}
139+
void operator delete(void *ptr, size_t size) { __builtin_trap(); }
144140

145141
// Defining members in the std namespace is not preferred. But, we do it here
146142
// so that we can use it to define the operator new which takes std::align_val_t
@@ -149,11 +145,8 @@ namespace std {
149145
enum class align_val_t : size_t {};
150146
} // namespace std
151147

152-
void operator delete([[maybe_unused]] void *mem, std::align_val_t) noexcept {
153-
__builtin_trap();
154-
}
148+
void operator delete(void *mem, std::align_val_t) noexcept { __builtin_trap(); }
155149

156-
void operator delete([[maybe_unused]] void *mem, unsigned int,
157-
std::align_val_t) noexcept {
150+
void operator delete(void *mem, unsigned int, std::align_val_t) noexcept {
158151
__builtin_trap();
159152
}

libc/test/UnitTest/LibcDeathTestExecutors.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
2222
namespace testing {
2323

2424
bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
25-
const char *LHSStr,
26-
[[maybe_unused]] const char *RHSStr,
25+
const char *LHSStr, const char *RHSStr,
2726
internal::Location Loc) {
2827
testutils::ProcessStatus Result =
2928
testutils::invoke_in_subprocess(Func, TIMEOUT_MS);

libc/test/UnitTest/LibcTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct Message {
8181
// A trivial object to catch the Message, this enables custom logging and
8282
// returning from the test function, see LIBC_TEST_SCAFFOLDING_ below.
8383
struct Failure {
84-
void operator=([[maybe_unused]] Message msg) {}
84+
void operator=(Message msg) {}
8585
};
8686

8787
struct RunContext {

libc/test/include/stdbit_stub.h

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,11 @@
1717
#include <stdbool.h> // bool in C
1818

1919
#define STDBIT_STUB_FUNCTION(FUNC_NAME, LEADING_VAL) \
20-
unsigned FUNC_NAME##_uc([[maybe_unused]] unsigned char x) { \
21-
return LEADING_VAL##AU; \
22-
} \
23-
unsigned FUNC_NAME##_us([[maybe_unused]] unsigned short x) { \
24-
return LEADING_VAL##BU; \
25-
} \
26-
unsigned FUNC_NAME##_ui([[maybe_unused]] unsigned int x) { \
27-
return LEADING_VAL##CU; \
28-
} \
29-
unsigned FUNC_NAME##_ul([[maybe_unused]] unsigned long x) { \
30-
return LEADING_VAL##DU; \
31-
} \
32-
unsigned FUNC_NAME##_ull([[maybe_unused]] unsigned long long x) { \
33-
return LEADING_VAL##EU; \
34-
}
20+
unsigned FUNC_NAME##_uc(unsigned char x) { return LEADING_VAL##AU; } \
21+
unsigned FUNC_NAME##_us(unsigned short x) { return LEADING_VAL##BU; } \
22+
unsigned FUNC_NAME##_ui(unsigned int x) { return LEADING_VAL##CU; } \
23+
unsigned FUNC_NAME##_ul(unsigned long x) { return LEADING_VAL##DU; } \
24+
unsigned FUNC_NAME##_ull(unsigned long long x) { return LEADING_VAL##EU; }
3525

3626
__BEGIN_C_DECLS
3727

@@ -46,42 +36,24 @@ STDBIT_STUB_FUNCTION(stdc_first_trailing_one, 0x1)
4636
STDBIT_STUB_FUNCTION(stdc_count_zeros, 0x2)
4737
STDBIT_STUB_FUNCTION(stdc_count_ones, 0x3)
4838

49-
bool stdc_has_single_bit_uc([[maybe_unused]] unsigned char x) { return false; }
50-
bool stdc_has_single_bit_us([[maybe_unused]] unsigned short x) { return false; }
51-
bool stdc_has_single_bit_ui([[maybe_unused]] unsigned x) { return false; }
52-
bool stdc_has_single_bit_ul([[maybe_unused]] unsigned long x) { return false; }
53-
bool stdc_has_single_bit_ull([[maybe_unused]] unsigned long long x) {
54-
return false;
55-
}
39+
bool stdc_has_single_bit_uc(unsigned char x) { return false; }
40+
bool stdc_has_single_bit_us(unsigned short x) { return false; }
41+
bool stdc_has_single_bit_ui(unsigned x) { return false; }
42+
bool stdc_has_single_bit_ul(unsigned long x) { return false; }
43+
bool stdc_has_single_bit_ull(unsigned long long x) { return false; }
5644

5745
STDBIT_STUB_FUNCTION(stdc_bit_width, 0x4)
5846

59-
unsigned char stdc_bit_floor_uc([[maybe_unused]] unsigned char x) {
60-
return 0x5AU;
61-
}
62-
unsigned short stdc_bit_floor_us([[maybe_unused]] unsigned short x) {
63-
return 0x5BU;
64-
}
65-
unsigned stdc_bit_floor_ui([[maybe_unused]] unsigned x) { return 0x5CU; }
66-
unsigned long stdc_bit_floor_ul([[maybe_unused]] unsigned long x) {
67-
return 0x5DUL;
68-
}
69-
unsigned long long stdc_bit_floor_ull([[maybe_unused]] unsigned long long x) {
70-
return 0x5EULL;
71-
}
72-
73-
unsigned char stdc_bit_ceil_uc([[maybe_unused]] unsigned char x) {
74-
return 0x6AU;
75-
}
76-
unsigned short stdc_bit_ceil_us([[maybe_unused]] unsigned short x) {
77-
return 0x6BU;
78-
}
79-
unsigned stdc_bit_ceil_ui([[maybe_unused]] unsigned x) { return 0x6CU; }
80-
unsigned long stdc_bit_ceil_ul([[maybe_unused]] unsigned long x) {
81-
return 0x6DUL;
82-
}
83-
unsigned long long stdc_bit_ceil_ull([[maybe_unused]] unsigned long long x) {
84-
return 0x6EULL;
85-
}
47+
unsigned char stdc_bit_floor_uc(unsigned char x) { return 0x5AU; }
48+
unsigned short stdc_bit_floor_us(unsigned short x) { return 0x5BU; }
49+
unsigned stdc_bit_floor_ui(unsigned x) { return 0x5CU; }
50+
unsigned long stdc_bit_floor_ul(unsigned long x) { return 0x5DUL; }
51+
unsigned long long stdc_bit_floor_ull(unsigned long long x) { return 0x5EULL; }
52+
53+
unsigned char stdc_bit_ceil_uc(unsigned char x) { return 0x6AU; }
54+
unsigned short stdc_bit_ceil_us(unsigned short x) { return 0x6BU; }
55+
unsigned stdc_bit_ceil_ui(unsigned x) { return 0x6CU; }
56+
unsigned long stdc_bit_ceil_ul(unsigned long x) { return 0x6DUL; }
57+
unsigned long long stdc_bit_ceil_ull(unsigned long long x) { return 0x6EULL; }
8658

8759
__END_C_DECLS

libc/test/integration/src/pthread/pthread_mutex_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ constexpr int MAX = 10000;
2323
pthread_mutex_t mutex;
2424
static int shared_int = START;
2525

26-
void *counter([[maybe_unused]] void *arg) {
26+
void *counter(void *arg) {
2727
int last_count = START;
2828
while (true) {
2929
LIBC_NAMESPACE::pthread_mutex_lock(&mutex);
@@ -72,7 +72,7 @@ void relay_counter() {
7272
pthread_mutex_t start_lock, step_lock;
7373
bool started, step;
7474

75-
void *stepper([[maybe_unused]] void *arg) {
75+
void *stepper(void *arg) {
7676
LIBC_NAMESPACE::pthread_mutex_lock(&start_lock);
7777
started = true;
7878
LIBC_NAMESPACE::pthread_mutex_unlock(&start_lock);

libc/test/integration/src/spawn/posix_spawn_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ void spawn_and_wait_for_normal_exit(char **envp) {
4545
ASSERT_EQ(exit_status, 0);
4646
}
4747

48-
TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
49-
char **envp) {
48+
TEST_MAIN(int argc, char **argv, char **envp) {
5049
spawn_and_wait_for_normal_exit(envp);
5150
return 0;
5251
}

libc/test/integration/src/spawn/posix_spawn_test_binary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <string.h>
33
#include <unistd.h>
44

5-
int main(int argc, [[maybe_unused]] char **argv) {
5+
int main(int argc, char **argv) {
66
if (argc != 1)
77
return 5;
88
constexpr size_t bufsize = sizeof(TEXT);

0 commit comments

Comments
 (0)