[libcxx-commits] [libcxx] [libc++][test] Avoid `-Wunused-variable` warnings in mutex tests (PR #94907)

Stephan T. Lavavej via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jun 9 10:46:28 PDT 2024


https://github.com/StephanTLavavej created https://github.com/llvm/llvm-project/pull/94907

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;
      |                             ^
```

>From e2f5aadc01da6737eb0af851fd4aa2c67973742f Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Sun, 9 Jun 2024 10:36:33 -0700
Subject: [PATCH] [libc++][test] Avoid `-Wunused-variable` warnings in mutex
 tests.

---
 .../thread.sharedtimedmutex.class/default.pass.cpp          | 6 +++---
 .../thread.timedmutex.class/default.pass.cpp                | 6 +++---
 .../thread.timedmutex.recursive/default.pass.cpp            | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

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



More information about the libcxx-commits mailing list