[libcxx-commits] [libcxx] [libc++][test] Avoid `-Wunused-variable` warnings in mutex tests (PR #94907)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jun 9 10:47:00 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Stephan T. Lavavej (StephanTLavavej)
<details>
<summary>Changes</summary>
After enhancing MSVC's STL to statically initialize our `condition_variable`, Clang began noticing that these mutex flavors were unused:
```
[...snipped...]\default.pass.cpp(23,22): error: unused variable 'm' [-Werror,-Wunused-variable]
23 | std::timed_mutex m;
| ^
[...snipped...]\default.pass.cpp(23,32): error: unused variable 'm' [-Werror,-Wunused-variable]
23 | std::recursive_timed_mutex m;
| ^
[...snipped...]\default.pass.cpp(24,29): error: unused variable 'm' [-Werror,-Wunused-variable]
24 | std::shared_timed_mutex m;
| ^
```
---
Full diff: https://github.com/llvm/llvm-project/pull/94907.diff
3 Files Affected:
- (modified) libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp (+3-3)
- (modified) libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp (+3-3)
- (modified) libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp (+3-3)
``````````diff
diff --git a/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp
index b278419df6eed..7a8d096994fff 100644
--- a/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp
+++ b/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp
@@ -19,9 +19,9 @@
#include "test_macros.h"
-int main(int, char**)
-{
- std::shared_timed_mutex m;
+int main(int, char**) {
+ std::shared_timed_mutex m;
+ (void)m;
return 0;
}
diff --git a/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
index d13a0ad435aea..c7f207372ac42 100644
--- a/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
+++ b/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
@@ -18,9 +18,9 @@
#include "test_macros.h"
-int main(int, char**)
-{
- std::timed_mutex m;
+int main(int, char**) {
+ std::timed_mutex m;
+ (void)m;
return 0;
}
diff --git a/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
index 73e2e7a3a5ab9..3096e031855a2 100644
--- a/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
+++ b/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
@@ -18,9 +18,9 @@
#include "test_macros.h"
-int main(int, char**)
-{
- std::recursive_timed_mutex m;
+int main(int, char**) {
+ std::recursive_timed_mutex m;
+ (void)m;
return 0;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/94907
More information about the libcxx-commits
mailing list