From 3a72496b5c43484a94882440993b0ca0cb842d8a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 16 Jul 2021 09:57:56 +0200 Subject: tests: fix some -Wvolatile C++20 deprecated compound volatile statements such as pre- and post-increments, to stress that they're not atomic. So instead of volatile i; ~~~~; ++i; you're now supposed to write volatile i; ~~~~; int j = i; // volatile load ++j; i = j; // volatile store which matches more closely what hardware does. Instead of fixing every use of volatile pre- or post-increment in this fashion individually, and realising that probably a few more Qt modules will have the same kind of code patterns in them, write QtPrivate functions to do the job centrally. Change-Id: I838097bd484ef2118c071726963f103c080d2ba5 Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qsharedpointer/CMakeLists.txt | 2 ++ tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/auto/corelib/tools/qsharedpointer') diff --git a/tests/auto/corelib/tools/qsharedpointer/CMakeLists.txt b/tests/auto/corelib/tools/qsharedpointer/CMakeLists.txt index f43b83b819..d29f203bf9 100644 --- a/tests/auto/corelib/tools/qsharedpointer/CMakeLists.txt +++ b/tests/auto/corelib/tools/qsharedpointer/CMakeLists.txt @@ -8,4 +8,6 @@ qt_internal_add_test(tst_qsharedpointer nontracked.cpp wrapper.cpp tst_qsharedpointer.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate ) diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index e6e3329ed3..48464aff58 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include "forwarddeclared.h" #include "nontracked.h" @@ -1944,7 +1945,7 @@ class ThreadData QAtomicInt * volatile ptr; public: ThreadData(QAtomicInt *p) : ptr(p) { } - ~ThreadData() { ++ptr; } + ~ThreadData() { QtPrivate::volatilePreIncrement(ptr); } void ref() { // if we're called after the destructor, we'll crash -- cgit v1.2.3