tst_QCompareHelpers::compareWithAttributes(): do not generate deprecation warnings
Some compilers do not respect the QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED ... QT_WARNING_POP incantation, so rewrite the test to use `template <typename X>` as an Attribute parameter of the macros. This allows to get rid of annoying warnings when compiling tst_qcomparehelpers. Amends de16185068a08e0cab8bf588c574899a19392410. Change-Id: I0b3a0f4ad3189d39f5662ce128d5e5f427543393 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit c6feed7e1d8b8ed991a81878c78bb361f038eaf6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
98ecccba8d
commit
31e247f9f8
@ -4,23 +4,26 @@
|
|||||||
#include "tst_qcomparehelpers.h"
|
#include "tst_qcomparehelpers.h"
|
||||||
|
|
||||||
#define DECLARE_TYPE(Name, Type, RetType, Constexpr, Suffix) \
|
#define DECLARE_TYPE(Name, Type, RetType, Constexpr, Suffix) \
|
||||||
class Deprecated ## Name \
|
class Templated ## Name \
|
||||||
{ \
|
{ \
|
||||||
public: \
|
public: \
|
||||||
Constexpr Deprecated ## Name () {} \
|
Constexpr Templated ## Name () {} \
|
||||||
\
|
\
|
||||||
private: \
|
private: \
|
||||||
|
template <typename X> \
|
||||||
friend Constexpr bool \
|
friend Constexpr bool \
|
||||||
comparesEqual(const Deprecated ## Name &lhs, int rhs) noexcept; \
|
comparesEqual(const Templated ## Name &lhs, X rhs) noexcept; \
|
||||||
|
template <typename X> \
|
||||||
friend Constexpr RetType \
|
friend Constexpr RetType \
|
||||||
compareThreeWay(const Deprecated ## Name &lhs, int rhs) noexcept; \
|
compareThreeWay(const Templated ## Name &lhs, X rhs) noexcept; \
|
||||||
Q_DECLARE_ ## Type ## _ORDERED ## Suffix (Deprecated ## Name, int, \
|
Q_DECLARE_ ## Type ## _ORDERED ## Suffix (Templated ## Name, X, template <typename X>) \
|
||||||
Q_DECL_DEPRECATED_X("This op is deprecated")) \
|
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
Constexpr bool comparesEqual(const Deprecated ## Name &lhs, int rhs) noexcept \
|
template <typename X> \
|
||||||
|
Constexpr bool comparesEqual(const Templated ## Name &lhs, X rhs) noexcept \
|
||||||
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return true; } \
|
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return true; } \
|
||||||
Constexpr RetType compareThreeWay(const Deprecated ## Name &lhs, int rhs) noexcept \
|
template <typename X> \
|
||||||
|
Constexpr RetType compareThreeWay(const Templated ## Name &lhs, X rhs) noexcept \
|
||||||
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return RetType::equivalent; }
|
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return RetType::equivalent; }
|
||||||
|
|
||||||
DECLARE_TYPE(PartialConst, PARTIALLY, Qt::partial_ordering, constexpr, _LITERAL_TYPE)
|
DECLARE_TYPE(PartialConst, PARTIALLY, Qt::partial_ordering, constexpr, _LITERAL_TYPE)
|
||||||
@ -34,10 +37,6 @@ DECLARE_TYPE(Strong, STRONGLY, Qt::strong_ordering, , )
|
|||||||
|
|
||||||
void tst_QCompareHelpers::compareWithAttributes()
|
void tst_QCompareHelpers::compareWithAttributes()
|
||||||
{
|
{
|
||||||
// All these comparisons would trigger deprecation warnings.
|
|
||||||
QT_WARNING_PUSH
|
|
||||||
QT_WARNING_DISABLE_DEPRECATED
|
|
||||||
|
|
||||||
#define COMPARE(ClassName) \
|
#define COMPARE(ClassName) \
|
||||||
do { \
|
do { \
|
||||||
ClassName c; \
|
ClassName c; \
|
||||||
@ -46,14 +45,12 @@ QT_WARNING_DISABLE_DEPRECATED
|
|||||||
QCOMPARE_GE(0, c); \
|
QCOMPARE_GE(0, c); \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
COMPARE(DeprecatedPartialConst);
|
COMPARE(TemplatedPartialConst);
|
||||||
COMPARE(DeprecatedPartial);
|
COMPARE(TemplatedPartial);
|
||||||
COMPARE(DeprecatedWeakConst);
|
COMPARE(TemplatedWeakConst);
|
||||||
COMPARE(DeprecatedWeak);
|
COMPARE(TemplatedWeak);
|
||||||
COMPARE(DeprecatedStrongConst);
|
COMPARE(TemplatedStrongConst);
|
||||||
COMPARE(DeprecatedStrong);
|
COMPARE(TemplatedStrong);
|
||||||
|
|
||||||
#undef COMPARE
|
#undef COMPARE
|
||||||
|
|
||||||
QT_WARNING_POP
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user