From f7db9a602a83b05ccad6ac33a2ab63acf3367481 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Sep 2010 09:34:43 +0200 Subject: delay next token fetching when opening namespace otherwise, if the next token to be fetched is a non-empty #define, it would save the context before entering the namespace, and thus the post-define context restore would just discard the namespace entry. Task-number: QTBUG-12683 --- .../lupdate/testdata/good/parsecpp/main.cpp | 25 ++++++++++++++++++++++ .../testdata/good/parsecpp/project.ts.result | 8 +++++++ tools/linguist/lupdate/cpp.cpp | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index c56ba7c..706e8d0 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -318,3 +318,28 @@ int LotsaFun::operator<<(int left, int right) tr("this is inside operator<<"); return left << right; } + + + +// QTBUG-12683: define in re-opened namespace +namespace NameSchpace { + +class YetMoreFun : public QObject +{ + Q_OBJECT +public: + void funStuff(); +}; + +} + +namespace NameSchpace { + +#define somevar 1 + +void YetMoreFun::funStuff() +{ + tr("funStuff!"); +} + +} 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 1a6d551..f73fc64 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -149,6 +149,14 @@ backslashed \ stuff. + NameSchpace::YetMoreFun + + + funStuff! + + + + Plurals, QCoreApplication diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 009d5a7..d701d7f 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -1704,7 +1704,6 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) HashString ns = HashString(text); yyTok = getToken(); if (yyTok == Tok_LeftBrace) { - yyTok = getToken(); namespaceDepths.push(namespaces.count()); enterNamespace(&namespaces, ns); @@ -1712,6 +1711,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) functionContextUnresolved.clear(); prospectiveContext.clear(); pendingContext.clear(); + yyTok = getToken(); } else if (yyTok == Tok_Equals) { // e.g. namespace Is = OuterSpace::InnerSpace; QList fullName; -- cgit v0.12