From 30b07c744f980c46ea8dac5c68bb0b94eb070323 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 26 Jul 2013 17:54:36 +0200 Subject: [PATCH] make QT_TR_NOOP work in static initializers, take 2 simply ignoring equal signs turns out to be not so smart: there are static initializers without braces, which consequently do not look like function definitions with a weird additional char. Task-number: QTBUG-9276 Change-Id: I7d200aee7b81f17b42866eca4830be388c8edb64 Reviewed-by: hjk Reviewed-by: Oswald Buddenhagen --- src/linguist/lupdate/cpp.cpp | 7 ++++--- tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp | 13 +++++++++++++ .../lupdate/testdata/good/parsecpp/project.ts.result | 5 +++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/linguist/lupdate/cpp.cpp b/src/linguist/lupdate/cpp.cpp index 226075a..202111e 100644 --- a/src/linguist/lupdate/cpp.cpp +++ b/src/linguist/lupdate/cpp.cpp @@ -2142,10 +2142,12 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac yyTok = getToken(); break; case Tok_Colon: + yyTokColonSeen = true; + // fallthrough + case Tok_Equals: if (!prospectiveContext.isEmpty() && yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0) pendingContext = prospectiveContext; - yyTokColonSeen = true; yyTok = getToken(); break; case Tok_LeftBrace: @@ -2162,8 +2164,7 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac if (!yyParenDepth) prospectiveContext.clear(); // fallthrough - case Tok_Equals: // for static initializers; other cases make no difference - case Tok_RightBracket: // ignoring indexing; same reason + case Tok_RightBracket: // ignoring indexing; for static initializers case_default: yyTok = getToken(); break; diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index 792d0dc..4f6de5c 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -352,3 +352,16 @@ void blubb() QMap d; d[LotsaFun::tr("bracketed")] = "plain"; } + + + +// QTBUG-9276 part 2: QT_TR_NOOP in static member initializers +class TestClass +{ + Q_DECLARE_TR_FUNCTIONS(TestClass); + +public: + static const char TEST_STRING[]; +}; + +const char TestClass::TEST_STRING[] = QT_TR_NOOP("Test value"); diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index c7367ca..d7c2b14 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -292,6 +292,11 @@ backslashed \ stuff. TestClass + + + Test value + + Testing -- 2.7.4