diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2021-06-30 13:37:24 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-06-30 21:13:28 +0000 |
commit | e160cded0ac6e08aaf3fdce55b567ed26bc40f34 (patch) | |
tree | b9f630779768bc76ac8882eb209c4e5db01a1c01 /src/corelib/global/qglobalstatic.h | |
parent | bc1808794db670432e5c98c1b94119748c808843 (diff) |
QGlobalStatic: fix warning when using cv-qualified types
Says GCC:
tst_qglobalstatic.cpp: In function ‘{anonymous}::Q_QGS_constInt::Type* {anonymous}::Q_QGS_constInt::innerFunction()’:
tst_qglobalstatic.cpp:71:51: warning: type qualifiers ignored on cast result type [-Wignored-qualifiers]
71 | Q_GLOBAL_STATIC_WITH_ARGS(const int, constInt, (42))
| ^
qglobalstatic.h:80:40: note: in definition of macro ‘Q_GLOBAL_STATIC_INTERNAL’
80 | noexcept(noexcept(Type ARGS))
| ^~~~
tst_qglobalstatic.cpp:71:1: note: in expansion of macro ‘Q_GLOBAL_STATIC_WITH_ARGS’
71 | Q_GLOBAL_STATIC_WITH_ARGS(const int, constInt, (42))
| ^~~~~~~~~~~~~~~~~~~~~~~~~
Fix by a strategic std::remove_cv_t.
Pick-to: 6.2 5.15
Change-Id: If2d81b7965cefdcf3ec115bafb78aabc78d4256c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qglobalstatic.h')
-rw-r--r-- | src/corelib/global/qglobalstatic.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 034ef274fa..4aa496e7f6 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -44,6 +44,8 @@ #include <QtCore/qatomic.h> +#include <type_traits> + QT_BEGIN_NAMESPACE namespace QtGlobalStatic { @@ -77,7 +79,7 @@ enum GuardValues { static struct Holder : public HolderBase { \ Type value; \ Holder() \ - noexcept(noexcept(Type ARGS)) \ + noexcept(noexcept(typename std::remove_cv<Type>::type ARGS)) \ : value ARGS \ { guard.storeRelaxed(QtGlobalStatic::Initialized); } \ } holder; \ |