[compiler-rt] [scudo] Avoid deprecated-volatile warning in HybridMutex::delayLoop (PR #67135)
Fabio D'Urso via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 22 06:21:21 PDT 2023
https://github.com/fabio-d created https://github.com/llvm/llvm-project/pull/67135
That can prevent compilation with -Werror and -std=c++20:
mutex.h:63:7: error: increment of object of volatile-qualified type 'volatile u32' (aka 'volatile unsigned int') is deprecated [-Werror,-Wdeprecated-volatile]
>From b6df00aebf63bd64bfa3923dca54717500fc4f8f Mon Sep 17 00:00:00 2001
From: Fabio D'Urso <fdurso at google.com>
Date: Fri, 22 Sep 2023 15:10:40 +0200
Subject: [PATCH] [scudo] Avoid deprecated-volatile warning in
HybridMutex::delayLoop
That can prevent compilation with -Werror and -std=c++20:
mutex.h:63:7: error: increment of object of volatile-qualified type 'volatile u32' (aka 'volatile unsigned int') is deprecated [-Werror,-Wdeprecated-volatile]
---
compiler-rt/lib/scudo/standalone/mutex.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/lib/scudo/standalone/mutex.h b/compiler-rt/lib/scudo/standalone/mutex.h
index 38108397b1654bb..1563cdb3fb109cb 100644
--- a/compiler-rt/lib/scudo/standalone/mutex.h
+++ b/compiler-rt/lib/scudo/standalone/mutex.h
@@ -58,9 +58,13 @@ class CAPABILITY("mutex") HybridMutex {
// are the fastest operations) so that we are unlikely to wait too long for
// fast operations.
constexpr u32 SpinTimes = 16;
- volatile u32 V = 0;
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+ volatile u32 V;
for (u32 I = 0; I < SpinTimes; ++I)
- ++V;
+ V = 0;
+#pragma GCC diagnostic pop
}
void assertHeldImpl();
More information about the llvm-commits
mailing list