From d7969320de23df0799b365dfbfd58569b143df00 Mon Sep 17 00:00:00 2001 From: Tatiana Borisova Date: Fri, 5 Jul 2024 16:07:48 +0200 Subject: [PATCH] clock_cast and utc_time aren't supported by incoming GHS compiler - The incoming GHS compiler version claims to support C++20, but doesn't support the clock_cast and utc_time. Also there is no concrete date or plan to add it. For future smooth switch to C++20 on INTEGRITY, disable the __cpp_lib_chrono >= 201907L usage there. Change-Id: I52dd5ac71bce2714d66f25ccd73e1703cd705267 Reviewed-by: Edward Welbourne --- src/corelib/global/q20chrono.h | 3 ++- src/corelib/time/qdatetime.h | 14 ++++++++----- tests/auto/corelib/time/qdate/tst_qdate.cpp | 20 +++++++++++-------- .../corelib/time/qdatetime/tst_qdatetime.cpp | 20 +++++++++++-------- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/corelib/global/q20chrono.h b/src/corelib/global/q20chrono.h index 19c2eabe3d1..8014b269e30 100644 --- a/src/corelib/global/q20chrono.h +++ b/src/corelib/global/q20chrono.h @@ -38,7 +38,8 @@ using IntRep = int64_t; using IntRep = int; #endif -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) using std::chrono::days; using std::chrono::weeks; using std::chrono::years; diff --git a/src/corelib/time/qdatetime.h b/src/corelib/time/qdatetime.h index 04b1954fc71..282731578e8 100644 --- a/src/corelib/time/qdatetime.h +++ b/src/corelib/time/qdatetime.h @@ -32,7 +32,8 @@ public: constexpr QDate() : jd(nullJd()) {} QDate(int y, int m, int d); QDate(int y, int m, int d, QCalendar cal); -#if __cpp_lib_chrono >= 201907L || defined(Q_QDOC) +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if (__cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY)) || defined(Q_QDOC) QT_POST_CXX17_API_IN_EXPORTED_CLASS Q_IMPLICIT constexpr QDate(std::chrono::year_month_day date) noexcept : jd(date.ok() ? stdSysDaysToJulianDay(date QT6_CALL_NEW_OVERLOAD_TAIL) : nullJd()) @@ -114,7 +115,8 @@ public: void getDate(int *year, int *month, int *day) const; [[nodiscard]] QDate addDays(qint64 days) const; -#if __cpp_lib_chrono >= 201907L || defined(Q_QDOC) +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if (__cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY)) || defined(Q_QDOC) QT_POST_CXX17_API_IN_EXPORTED_CLASS [[nodiscard]] QDate addDuration(std::chrono::days days) const { @@ -176,7 +178,8 @@ private: static constexpr inline qint64 maxJd() { return Q_INT64_C( 784354017364); } static constexpr inline qint64 unixEpochJd() { return Q_INT64_C(2440588); } -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) QT_POST_CXX17_API_IN_EXPORTED_CLASS static constexpr qint64 stdSysDaysToJulianDay(const std::chrono::sys_days &days QT6_DECL_NEW_OVERLOAD_TAIL) noexcept @@ -515,7 +518,8 @@ public: > time ); -#if __cpp_lib_chrono >= 201907L || defined(Q_QDOC) +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if (__cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY)) || defined(Q_QDOC) #if __cpp_concepts >= 201907L || defined(Q_QDOC) private: // The duration type of the result of a clock_cast. @@ -585,7 +589,7 @@ public: const std::chrono::seconds duration(toSecsSinceEpoch()); return std::chrono::sys_seconds(duration); } -#endif // __cpp_lib_chrono >= 201907L +#endif // __cpp_lib_chrono >= 201907L && !Q_OS_INTEGRITY friend std::chrono::milliseconds operator-(const QDateTime &lhs, const QDateTime &rhs) { diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 5b715e8c55d..954724ba3f4 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -192,7 +192,8 @@ void tst_QDate::isValid_data() QTest::newRow("jd latest formula") << 1400000 << 12 << 31 << qint64(513060925) << true; } -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) // QDate has a bigger range than year_month_date. The tests use this bigger // range. However building a year_month_time with "out of range" data has // unspecified results, so don't do that. See [time.cal.year], @@ -237,7 +238,8 @@ void tst_QDate::isValid() QCOMPARE(d.year(), year); QCOMPARE(d.month(), month); QCOMPARE(d.day(), day); -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) std::optional ymd = convertToStdYearMonthDay(year, month, day); if (ymd) { QDate d = *ymd; @@ -820,8 +822,8 @@ void tst_QDate::addDays() QCOMPARE( dt2.year(), expectedYear ); QCOMPARE( dt2.month(), expectedMonth ); QCOMPARE( dt2.day(), expectedDay ); - -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) QDate dt3 = dt.addDuration( std::chrono::days( amountToAdd ) ); QCOMPARE( dt3.year(), expectedYear ); @@ -997,7 +999,8 @@ void tst_QDate::daysTo() void tst_QDate::orderingCompiles() { QTestPrivate::testAllComparisonOperatorsCompile(); -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) QTestPrivate::testAllComparisonOperatorsCompile(); QTestPrivate::testAllComparisonOperatorsCompile(); QTestPrivate::testAllComparisonOperatorsCompile(); @@ -1080,7 +1083,8 @@ void tst_QDate::ordering() void tst_QDate::ordering_chrono_types() { -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) using namespace std::chrono; QDate friday(2001, 11, 30); // the 5th Friday of November 2001 // std::chrono::year_month_day @@ -1713,8 +1717,8 @@ void tst_QDate::roundtrip() const QCOMPARE(loopDate.toJulianDay(), testDate.toJulianDay()); loopDate = loopDate.addDays(1); } - -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) // Test roundtrip for from/to std::chrono conversions. // Compile-time test, to verify it's all constexpr. using namespace std::chrono; diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index f9c6afc795c..c5d86f7bc30 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -4618,15 +4618,16 @@ void tst_QDateTime::macTypes() tst_QDateTime_macTypes(); #endif } - -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) using StdSysMillis = std::chrono::sys_time; Q_DECLARE_METATYPE(StdSysMillis); #endif void tst_QDateTime::stdCompatibilitySysTime_data() { -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) QTest::addColumn("sysTime"); QTest::addColumn("expected"); @@ -4676,7 +4677,8 @@ void tst_QDateTime::stdCompatibilitySysTime_data() void tst_QDateTime::stdCompatibilitySysTime() { -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) QFETCH(StdSysMillis, sysTime); QFETCH(QDateTime, expected); @@ -4715,15 +4717,16 @@ void tst_QDateTime::stdCompatibilitySysTime() QSKIP("This test requires C++20's ."); #endif } - -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) using StdLocalMillis = std::chrono::local_time; Q_DECLARE_METATYPE(StdLocalMillis); #endif void tst_QDateTime::stdCompatibilityLocalTime_data() { -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) QTest::addColumn("localTime"); QTest::addColumn("expected"); @@ -4762,7 +4765,8 @@ void tst_QDateTime::stdCompatibilityLocalTime_data() void tst_QDateTime::stdCompatibilityLocalTime() { -#if __cpp_lib_chrono >= 201907L +// INTEGRITY incident-85878 (timezone and clock_cast are not supported) +#if __cpp_lib_chrono >= 201907L && !defined(Q_OS_INTEGRITY) QFETCH(StdLocalMillis, localTime); QFETCH(QDateTime, expected);