From 62d02c1d509780eca7d3a4c35ac64a0d475d0fe7 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 12 Apr 2024 12:49:18 +0200 Subject: moc: Treat number + characters as Identifier, not Number While + is not a valid identifier by itself in the C++ language, it might become one when using it with the token pasting operator. This risks confusing some number literals with suffix as Identifiers, but those are currently not supported anyway, so this shouldn't break anything that is currently working. Fixes: QTBUG-87219 Fixes: QTBUG-124288 Pick-to: 6.7 Change-Id: If73255cc0e6649bc90c52b1d177aac8ff975ae69 Reviewed-by: Ivan Solovev Reviewed-by: Ulf Hermann --- src/tools/moc/preprocessor.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/tools/moc/preprocessor.cpp') diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index f0a61ce621..11ea8d417e 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -214,7 +214,9 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso data -= 2; break; case DIGIT: - while (isAsciiDigit(*data) || *data == '\'') + { + bool hasSeenTokenSeparator = false;; + while (isAsciiDigit(*data) || (hasSeenTokenSeparator = *data == '\'')) ++data; if (!*data || *data != '.') { token = INTEGER_LITERAL; @@ -223,15 +225,22 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso || *data == 'b' || *data == 'B') && *lexem == '0') { ++data; - while (isHexDigit(*data) || *data == '\'') + while (isHexDigit(*data) || (hasSeenTokenSeparator = *data == '\'')) ++data; } else if (*data == 'L') // TODO: handle other suffixes ++data; + if (!hasSeenTokenSeparator) { + while (is_ident_char(*data)) { + ++data; + token = IDENTIFIER; + } + } break; } token = FLOATING_LITERAL; ++data; Q_FALLTHROUGH(); + } case FLOATING_LITERAL: while (isAsciiDigit(*data) || *data == '\'') ++data; -- cgit v1.2.3