From 31e247f9f8d7a9084c5caa796179a501708e1c0a Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Mon, 3 Jun 2024 15:26:53 +0200 Subject: [PATCH] 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 ` 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 (cherry picked from commit c6feed7e1d8b8ed991a81878c78bb361f038eaf6) Reviewed-by: Qt Cherry-pick Bot --- .../qcomparehelpers/tst_qcomparehelpers1.cpp | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers1.cpp b/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers1.cpp index a3b8200a63f..16b2842de27 100644 --- a/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers1.cpp +++ b/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers1.cpp @@ -4,23 +4,26 @@ #include "tst_qcomparehelpers.h" #define DECLARE_TYPE(Name, Type, RetType, Constexpr, Suffix) \ -class Deprecated ## Name \ +class Templated ## Name \ { \ public: \ - Constexpr Deprecated ## Name () {} \ + Constexpr Templated ## Name () {} \ \ private: \ + template \ friend Constexpr bool \ - comparesEqual(const Deprecated ## Name &lhs, int rhs) noexcept; \ + comparesEqual(const Templated ## Name &lhs, X rhs) noexcept; \ + template \ friend Constexpr RetType \ - compareThreeWay(const Deprecated ## Name &lhs, int rhs) noexcept; \ - Q_DECLARE_ ## Type ## _ORDERED ## Suffix (Deprecated ## Name, int, \ - Q_DECL_DEPRECATED_X("This op is deprecated")) \ + compareThreeWay(const Templated ## Name &lhs, X rhs) noexcept; \ + Q_DECLARE_ ## Type ## _ORDERED ## Suffix (Templated ## Name, X, template ) \ }; \ \ -Constexpr bool comparesEqual(const Deprecated ## Name &lhs, int rhs) noexcept \ +template \ +Constexpr bool comparesEqual(const Templated ## Name &lhs, X rhs) noexcept \ { Q_UNUSED(lhs); Q_UNUSED(rhs); return true; } \ -Constexpr RetType compareThreeWay(const Deprecated ## Name &lhs, int rhs) noexcept \ +template \ +Constexpr RetType compareThreeWay(const Templated ## Name &lhs, X rhs) noexcept \ { Q_UNUSED(lhs); Q_UNUSED(rhs); return RetType::equivalent; } 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() { - // All these comparisons would trigger deprecation warnings. -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - #define COMPARE(ClassName) \ do { \ ClassName c; \ @@ -46,14 +45,12 @@ QT_WARNING_DISABLE_DEPRECATED QCOMPARE_GE(0, c); \ } while (false) - COMPARE(DeprecatedPartialConst); - COMPARE(DeprecatedPartial); - COMPARE(DeprecatedWeakConst); - COMPARE(DeprecatedWeak); - COMPARE(DeprecatedStrongConst); - COMPARE(DeprecatedStrong); + COMPARE(TemplatedPartialConst); + COMPARE(TemplatedPartial); + COMPARE(TemplatedWeakConst); + COMPARE(TemplatedWeak); + COMPARE(TemplatedStrongConst); + COMPARE(TemplatedStrong); #undef COMPARE - -QT_WARNING_POP }