summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-09-09 16:34:18 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-09-10 14:31:24 (GMT)
commitc2d6eb9dca7546bbe8d9c6c62db683615e4b23a7 (patch)
treec3620e8161ef6afd38c0f9eb01271587c667fe8f
parent94584dcdd02e2c08e05ca75f6f8b460c0c320947 (diff)
downloadQt-c2d6eb9dca7546bbe8d9c6c62db683615e4b23a7.zip
Qt-c2d6eb9dca7546bbe8d9c6c62db683615e4b23a7.tar.gz
Qt-c2d6eb9dca7546bbe8d9c6c62db683615e4b23a7.tar.bz2
don't let operator overloads confuse us
Task-number: QTBUG-11426
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp16
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result8
-rw-r--r--tools/linguist/lupdate/cpp.cpp15
3 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
index f58f932..c56ba7c 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
@@ -302,3 +302,19 @@ static inline QString message2()
}
}
+
+
+
+// QTBUG-11426: operator overloads
+class LotsaFun : public QObject
+{
+ Q_OBJECT
+public:
+ int operator<<(int left, int right);
+};
+
+int LotsaFun::operator<<(int left, int right)
+{
+ tr("this is inside operator<<");
+ return left << right;
+}
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 7ac318e..1a6d551 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
@@ -141,6 +141,14 @@ backslashed \ stuff.</source>
</message>
</context>
<context>
+ <name>LotsaFun</name>
+ <message>
+ <location filename="main.cpp" line="318"/>
+ <source>this is inside operator&lt;&lt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
<name>Plurals, QCoreApplication</name>
<message numerus="yes">
<location filename="main.cpp" line="81"/>
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index 970d44b..009d5a7 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -489,6 +489,7 @@ STRING(class);
STRING(findMessage);
STRING(friend);
STRING(namespace);
+STRING(operator);
STRING(qtTrId);
STRING(return);
STRING(struct);
@@ -753,6 +754,20 @@ uint CppParser::getToken()
if (yyWord == strnamespace)
return Tok_namespace;
break;
+ case 'o':
+ if (yyWord == stroperator) {
+ // Operator overload declaration/definition.
+ // We need to prevent those characters from confusing the followup
+ // parsing. Actually using them does not add value, so just eat them.
+ while (isspace(yyCh))
+ yyCh = getChar();
+ while (yyCh == '+' || yyCh == '-' || yyCh == '*' || yyCh == '/' || yyCh == '%'
+ || yyCh == '=' || yyCh == '<' || yyCh == '>' || yyCh == '!'
+ || yyCh == '&' || yyCh == '|' || yyCh == '~' || yyCh == '^'
+ || yyCh == '[' || yyCh == ']')
+ yyCh = getChar();
+ }
+ break;
case 'q':
if (yyWord == strqtTrId)
return Tok_trid;