diff options
-rw-r--r-- | src/linguist/lupdate/cpp.cpp | 13 | ||||
-rw-r--r-- | tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp | 19 | ||||
-rw-r--r-- | tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result | 43 |
3 files changed, 75 insertions, 0 deletions
diff --git a/src/linguist/lupdate/cpp.cpp b/src/linguist/lupdate/cpp.cpp index 7779bd99e..bf1d358b6 100644 --- a/src/linguist/lupdate/cpp.cpp +++ b/src/linguist/lupdate/cpp.cpp @@ -335,6 +335,14 @@ CppParser::TokenType CppParser::lookAheadToSemicolonOrLeftBrace() } } +static bool isStringLiteralPrefix(const QStringView s) +{ + return s == u"L"_s + || s == u"U"_s + || s == u"u"_s + || s == u"u8"_s; +} + static const QString strQ_OBJECT = u"Q_OBJECT"_s; static const QString strclass = u"class"_s; static const QString strenum = u"enum"_s; @@ -564,6 +572,11 @@ CppParser::TokenType CppParser::getToken() //qDebug() << "IDENT: " << yyWord; + if (yyCh == '"' && isStringLiteralPrefix(yyWord)) { + // Handle prefixed string literals as ordinary string literals. + continue; + } + switch (yyWord.unicode()[0].unicode()) { case 'N': if (yyWord == strNULL) diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp index a4188c4d3..7abc1ac0a 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp @@ -147,3 +147,22 @@ struct IntLiteralsWithSeparators { int x = 0x1'AF'FE; int X = 0X2'E5E7; }; + + +// QTBUG-59802: prefixed string literals +class PrefixedStringLiterals : public QObject { + Q_OBJECT + void foo() + { + #if 0 + tr(u8"UTF-8 string literal"); + tr(u8R"(UTF-8 raw string literal)"); + tr(u"UTF-16 string literal"); + tr(uR"(UTF-16 raw string literal)"); + tr(U"UTF-32 string literal"); + tr(UR"(UTF-32 raw string literal)"); + tr(L"wide string literal"); + tr(LR"(wide raw string literal)"); + #endif + } +}; diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result index 0710915de..63885debf 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result @@ -18,6 +18,49 @@ </message> </context> <context> + <name>PrefixedStringLiterals</name> + <message> + <location filename="main.cpp" line="158"/> + <source>UTF-8 string literal</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="159"/> + <source>UTF-8 raw string literal</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="160"/> + <source>UTF-16 string literal</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="161"/> + <source>UTF-16 raw string literal</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="162"/> + <source>UTF-32 string literal</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="163"/> + <source>UTF-32 raw string literal</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="164"/> + <source>wide string literal</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="165"/> + <source>wide raw string literal</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>QObject</name> <message> <location filename="main.cpp" line="107"/> |