From 42fbd063e24855df444f31e8c4b8ef25416d111c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 11 Aug 2022 08:53:05 +0200 Subject: [PATCH] QStringConverter: fix -Wc++20-compat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 13 warns: qstringconverter_p.h:29:6: warning: identifier ‘char8_t’ is a keyword in C++20 [-Wc++20-compat] 29 | enum char8_t : uchar {}; Fix by calling the replacement qchar8_t (and making it a typedef to char8_t when the latter is available). Pick-to: 6.4 6.3 6.2 Change-Id: If59a9d55667bf1f5245e3a34189687995b000daa Reviewed-by: Ville Voutilainen Reviewed-by: Thiago Macieira --- src/corelib/text/qstringconverter.cpp | 8 ++++---- src/corelib/text/qstringconverter_p.h | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index 0217dc1fe8..c5d17e399e 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -250,7 +250,7 @@ static inline const uchar *simdFindNonAscii(const uchar *src, const uchar *end, // Compare only the US-ASCII beginning of [src8, end8) and [src16, end16) // and advance src8 and src16 to the first character that could not be compared -static void simdCompareAscii(const char8_t *&src8, const char8_t *end8, const char16_t *&src16, const char16_t *end16) +static void simdCompareAscii(const qchar8_t *&src8, const qchar8_t *end8, const char16_t *&src16, const char16_t *end16) { int bitSpacing = 1; qptrdiff len = qMin(end8 - src8, end16 - src16); @@ -436,7 +436,7 @@ static inline const uchar *simdFindNonAscii(const uchar *src, const uchar *end, return src; } -static void simdCompareAscii(const char8_t *&, const char8_t *, const char16_t *&, const char16_t *) +static void simdCompareAscii(const qchar8_t *&, const qchar8_t *, const char16_t *&, const char16_t *) { } #else @@ -456,7 +456,7 @@ static inline const uchar *simdFindNonAscii(const uchar *src, const uchar *end, return src; } -static void simdCompareAscii(const char8_t *&, const char8_t *, const char16_t *&, const char16_t *) +static void simdCompareAscii(const qchar8_t *&, const qchar8_t *, const char16_t *&, const char16_t *) { } #endif @@ -807,7 +807,7 @@ QUtf8::ValidUtf8Result QUtf8::isValidUtf8(QByteArrayView in) int QUtf8::compareUtf8(QByteArrayView utf8, QStringView utf16) noexcept { - auto src1 = reinterpret_cast(utf8.data()); + auto src1 = reinterpret_cast(utf8.data()); auto end1 = src1 + utf8.size(); auto src2 = reinterpret_cast(utf16.data()); auto end2 = src2 + utf16.size(); diff --git a/src/corelib/text/qstringconverter_p.h b/src/corelib/text/qstringconverter_p.h index 7533e094a9..5929fe0800 100644 --- a/src/corelib/text/qstringconverter_p.h +++ b/src/corelib/text/qstringconverter_p.h @@ -24,7 +24,9 @@ QT_BEGIN_NAMESPACE #ifndef __cpp_char8_t -enum char8_t : uchar {}; +enum qchar8_t : uchar {}; +#else +using qchar8_t = char8_t; #endif struct QUtf8BaseTraits @@ -38,25 +40,25 @@ struct QUtf8BaseTraits static void appendByte(uchar *&ptr, uchar b) { *ptr++ = b; } - static void appendByte(char8_t *&ptr, char8_t b) + static void appendByte(qchar8_t *&ptr, qchar8_t b) { *ptr++ = b; } static uchar peekByte(const uchar *ptr, qsizetype n = 0) { return ptr[n]; } - static uchar peekByte(const char8_t *ptr, qsizetype n = 0) + static uchar peekByte(const qchar8_t *ptr, qsizetype n = 0) { return ptr[n]; } static qptrdiff availableBytes(const uchar *ptr, const uchar *end) { return end - ptr; } - static qptrdiff availableBytes(const char8_t *ptr, const char8_t *end) + static qptrdiff availableBytes(const qchar8_t *ptr, const qchar8_t *end) { return end - ptr; } static void advanceByte(const uchar *&ptr, qsizetype n = 1) { ptr += n; } - static void advanceByte(const char8_t *&ptr, qsizetype n = 1) + static void advanceByte(const qchar8_t *&ptr, qsizetype n = 1) { ptr += n; } static void appendUtf16(char16_t *&ptr, char16_t uc)