From e652fa4d3e0f444f7a42d6a00cc39cf3ab79a6ec Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 14 Oct 2021 10:08:58 -0700 Subject: [PATCH] Q_GLOBAL_STATIC: suppress warning about expressions in noexcept() We use a simple statement to try and mark the holder as noexcept and that works for most cases (but not all). It triggers a warning when the expression is complex, though, like this in qlocale.cpp: Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer, defaultLocalePrivate, (new QLocalePrivate(defaultData(), defaultIndex()))) Pick-to: 6.2 Change-Id: Iea05060bc2c046928536fffd16adf4be6126d039 Reviewed-by: Ievgenii Meshcheriakov Reviewed-by: Volker Hilsheimer --- src/corelib/global/qglobalstatic.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 4aa496e7f6..49cebe1e61 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -122,6 +122,8 @@ struct QGlobalStatic }; #define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ + QT_WARNING_PUSH \ + QT_WARNING_DISABLE_CLANG("-Wunevaluated-expression") \ namespace { namespace Q_QGS_ ## NAME { \ typedef TYPE Type; \ QBasicAtomicInt guard = Q_BASIC_ATOMIC_INITIALIZER(QtGlobalStatic::Uninitialized); \ @@ -129,7 +131,8 @@ struct QGlobalStatic } } \ static QGlobalStatic NAME; + Q_QGS_ ## NAME::guard> NAME; \ + QT_WARNING_POP #define Q_GLOBAL_STATIC(TYPE, NAME) \ Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ())