ignore bracketed expressions only outside function scope
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>
Tue, 30 Jul 2013 10:05:31 +0000 (12:05 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 1 Aug 2013 11:36:59 +0000 (13:36 +0200)
static initializers obviously cannot appear in scopes, so there is no
reason to suppress parsing tr() statements used for indexing inside
functions.

Task-number: QTBUG-29998
Change-Id: I3a0330e1382cd5a74106328ae6722a02af282f7f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
src/linguist/lupdate/cpp.cpp
tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result

index b6222e6..226075a 100644 (file)
@@ -1616,7 +1616,7 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac
         // so they don't confuse our scoping of static initializers.
         // we enter the loop by either reading a left bracket or by an
         // #else popping the state.
-        if (yyBracketDepth) {
+        if (yyBracketDepth && yyBraceDepth == namespaceDepths.count()) {
             yyTok = getToken();
             continue;
         }
index 0db9a83..792d0dc 100644 (file)
@@ -343,3 +343,12 @@ void YetMoreFun::funStuff()
 }
 
 }
+
+
+
+// QTBUG-29998: tr() macro inside square brackets
+void blubb()
+{
+    QMap<QString, QString> d;
+    d[LotsaFun::tr("bracketed")] = "plain";
+}
index c8cca3f..c7367ca 100644 (file)
@@ -147,6 +147,11 @@ backslashed \ stuff.</source>
         <source>this is inside operator&lt;&lt;</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <location filename="main.cpp" line="353"/>
+        <source>bracketed</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>NameSchpace::YetMoreFun</name>