summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-08-19 19:11:37 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-09-06 18:31:43 +0200
commit68198de4dbe71ae97dc733606871f51bde804c1e (patch)
treedf68d428265f876367c7cd54d5e2c14f007c1964 /src/corelib
parentd3ff95dcb84861e8f42b480910d822b4ca8715b1 (diff)
Use C++17 [[maybe_unused]]
In some places needs to be ordered before const/constexpr though. Change-Id: I57a521ac0ad22b5a018761c4d52befbef69d64c0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qcompilerdetection.h5
-rw-r--r--src/corelib/global/qglobal.h20
-rw-r--r--src/corelib/global/qnamespace.h2
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder.cpp2
-rw-r--r--src/corelib/kernel/qsystemerror.cpp4
-rw-r--r--src/corelib/serialization/qcborstreamreader.cpp2
-rw-r--r--src/corelib/serialization/qcborstreamwriter.cpp4
7 files changed, 22 insertions, 17 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index a287bebc26..f88640dd81 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1135,6 +1135,11 @@
# define Q_REQUIRED_RESULT [[nodiscard]]
#endif
+#if __has_cpp_attribute(maybe_unused)
+# undef Q_DECL_UNUSED
+# define Q_DECL_UNUSED [[maybe_unused]]
+#endif
+
#if defined(__cpp_enumerator_attributes) && __cpp_enumerator_attributes >= 201411
#if defined(Q_CC_MSVC)
// Can't mark enum values as __declspec(deprecated) with MSVC, also can't move
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 642ea2b1f3..d32f1b420c 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -380,7 +380,7 @@ typedef double qreal;
// A tag to help mark stuff deprecated (cf. QStringViewLiteral)
namespace QtPrivate {
enum class Deprecated_t {};
-constexpr Q_DECL_UNUSED Deprecated_t Deprecated = {};
+Q_DECL_UNUSED constexpr Deprecated_t Deprecated = {};
}
#endif
@@ -868,22 +868,22 @@ typedef void (*QFunctionPointer)();
# define Q_UNIMPLEMENTED() qWarning("Unimplemented code.")
#endif
-Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qFuzzyCompare(double p1, double p2)
+Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyCompare(double p1, double p2)
{
return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2)));
}
-Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qFuzzyCompare(float p1, float p2)
+Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyCompare(float p1, float p2)
{
return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2)));
}
-Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qFuzzyIsNull(double d)
+Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyIsNull(double d)
{
return qAbs(d) <= 0.000000000001;
}
-Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qFuzzyIsNull(float f)
+Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyIsNull(float f)
{
return qAbs(f) <= 0.00001f;
}
@@ -891,12 +891,12 @@ Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qFuzzyIsNull(float
QT_WARNING_PUSH
QT_WARNING_DISABLE_FLOAT_COMPARE
-Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qIsNull(double d) noexcept
+Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qIsNull(double d) noexcept
{
return d == 0.0;
}
-Q_REQUIRED_RESULT constexpr static inline Q_DECL_UNUSED bool qIsNull(float f) noexcept
+Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qIsNull(float f) noexcept
{
return f == 0.0f;
}
@@ -1219,9 +1219,9 @@ struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
};
#if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 // C++14
-template <typename... Args> constexpr Q_DECL_UNUSED QOverload<Args...> qOverload = {};
-template <typename... Args> constexpr Q_DECL_UNUSED QConstOverload<Args...> qConstOverload = {};
-template <typename... Args> constexpr Q_DECL_UNUSED QNonConstOverload<Args...> qNonConstOverload = {};
+template <typename... Args> Q_DECL_UNUSED constexpr QOverload<Args...> qOverload = {};
+template <typename... Args> Q_DECL_UNUSED constexpr QConstOverload<Args...> qConstOverload = {};
+template <typename... Args> Q_DECL_UNUSED constexpr QNonConstOverload<Args...> qNonConstOverload = {};
#endif
#endif
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 0c4b4fc8bf..6edd84534b 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1606,7 +1606,7 @@ namespace Qt {
enum class Initialization {
Uninitialized
};
- static constexpr Q_DECL_UNUSED Initialization Uninitialized = Initialization::Uninitialized;
+ Q_DECL_UNUSED static constexpr Initialization Uninitialized = Initialization::Uninitialized;
#else
enum Initialization {
Uninitialized
diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp
index e451e5cf41..f4d5ea4f1a 100644
--- a/src/corelib/kernel/qmetaobjectbuilder.cpp
+++ b/src/corelib/kernel/qmetaobjectbuilder.cpp
@@ -89,7 +89,7 @@ Q_CORE_EXPORT bool isBuiltinType(const QByteArray &type)
} // namespace QtPrivate
// copied from qmetaobject.cpp
-static inline Q_DECL_UNUSED const QMetaObjectPrivate *priv(const uint* data)
+Q_DECL_UNUSED static inline const QMetaObjectPrivate *priv(const uint* data)
{ return reinterpret_cast<const QMetaObjectPrivate*>(data); }
class QMetaMethodBuilderPrivate
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 6a250f5f3a..619f94c476 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -61,11 +61,11 @@ namespace {
// version in portable code. However, it's impossible to do that if
// _GNU_SOURCE is defined so we use C++ overloading to decide what to do
// depending on the return type
- static inline Q_DECL_UNUSED QString fromstrerror_helper(int, const QByteArray &buf)
+ Q_DECL_UNUSED static inline QString fromstrerror_helper(int, const QByteArray &buf)
{
return QString::fromLocal8Bit(buf);
}
- static inline Q_DECL_UNUSED QString fromstrerror_helper(const char *str, const QByteArray &)
+ Q_DECL_UNUSED static inline QString fromstrerror_helper(const char *str, const QByteArray &)
{
return QString::fromLocal8Bit(str);
}
diff --git a/src/corelib/serialization/qcborstreamreader.cpp b/src/corelib/serialization/qcborstreamreader.cpp
index c5d0c855e3..553f40e4bf 100644
--- a/src/corelib/serialization/qcborstreamreader.cpp
+++ b/src/corelib/serialization/qcborstreamreader.cpp
@@ -74,7 +74,7 @@ static CborError _cbor_value_dup_string(const CborValue *, void **, size_t *, Cb
Q_UNREACHABLE();
return CborErrorInternalError;
}
-static CborError Q_DECL_UNUSED cbor_value_get_half_float_as_float(const CborValue *, float *)
+Q_DECL_UNUSED static CborError cbor_value_get_half_float_as_float(const CborValue *, float *)
{
Q_UNREACHABLE();
return CborErrorInternalError;
diff --git a/src/corelib/serialization/qcborstreamwriter.cpp b/src/corelib/serialization/qcborstreamwriter.cpp
index 51d4fefb6b..b3a5ed6eee 100644
--- a/src/corelib/serialization/qcborstreamwriter.cpp
+++ b/src/corelib/serialization/qcborstreamwriter.cpp
@@ -63,13 +63,13 @@ QT_WARNING_POP
// silence compilers that complain about this being a static function declared
// but never defined
-static CborError Q_DECL_UNUSED cbor_encoder_close_container_checked(CborEncoder*, const CborEncoder*)
+Q_DECL_UNUSED static CborError cbor_encoder_close_container_checked(CborEncoder*, const CborEncoder*)
{
Q_UNREACHABLE();
return CborErrorInternalError;
}
-static CborError Q_DECL_UNUSED cbor_encode_float_as_half_float(CborEncoder *, float)
+Q_DECL_UNUSED static CborError cbor_encode_float_as_half_float(CborEncoder *, float)
{
Q_UNREACHABLE();
return CborErrorInternalError;