make QT_TR_NOOP work in static initializers, take 2
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>
Fri, 26 Jul 2013 15:54:36 +0000 (17:54 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 1 Aug 2013 11:37:25 +0000 (13:37 +0200)
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 <hjk121@nokiamail.com>
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 226075a..202111e 100644 (file)
@@ -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;
index 792d0dc..4f6de5c 100644 (file)
@@ -352,3 +352,16 @@ void blubb()
     QMap<QString, QString> 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");
index c7367ca..d7c2b14 100644 (file)
@@ -292,6 +292,11 @@ backslashed \ stuff.</source>
         <comment>TestClass</comment>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <location filename="main.cpp" line="367"/>
+        <source>Test value</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>Testing</name>