From 3256b7b2ef7073264af3197bdcd62f4f9fe92ea1 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gorszkowski Date: Sun, 11 Aug 2013 22:10:26 +0200 Subject: C++: fix matching type with using from other namespace example code: struct S { int s; }; namespace std { template struct shared_ptr { T* operator->(); }; } namespace NS { using std::shared_ptr; } int main() { NS::shared_ptr p;// for this shared_ptr return 0; } Fixes: * find usages * follow symbol * highlighting * marking Task-number: QTCREATORBUG-7978 Change-Id: I28994c960b87ddd400e1d7b860fca6c6683bbb5a Reviewed-by: Erik Verbruggen --- tests/auto/cplusplus/findusages/tst_findusages.cpp | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests/auto/cplusplus/findusages/tst_findusages.cpp') diff --git a/tests/auto/cplusplus/findusages/tst_findusages.cpp b/tests/auto/cplusplus/findusages/tst_findusages.cpp index 9ab9d41af8..afc8ba35bb 100644 --- a/tests/auto/cplusplus/findusages/tst_findusages.cpp +++ b/tests/auto/cplusplus/findusages/tst_findusages.cpp @@ -108,6 +108,8 @@ private Q_SLOTS: void using_insideNamespace(); void using_insideFunction(); void templatedFunction_QTCREATORBUG9749(); + + void usingInDifferentNamespace_QTCREATORBUG7978(); }; void tst_FindUsages::dump(const QList &usages) const @@ -866,5 +868,44 @@ void tst_FindUsages::templatedFunction_QTCREATORBUG9749() QCOMPARE(findUsages.usages().size(), 2); } +void tst_FindUsages::usingInDifferentNamespace_QTCREATORBUG7978() +{ + const QByteArray src = "\n" + "struct S {};\n" + "namespace std\n" + "{\n" + " template struct shared_ptr{};\n" + "}\n" + "namespace NS\n" + "{\n" + " using std::shared_ptr;\n" + "}\n" + "void fun()\n" + "{\n" + " NS::shared_ptr p;\n" + "}\n" + ; + + Document::Ptr doc = Document::create("usingInDifferentNamespace_QTCREATORBUG7978"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QCOMPARE(doc->globalSymbolCount(), 4U); + + Snapshot snapshot; + snapshot.insert(doc); + + Namespace *ns = doc->globalSymbolAt(1)->asNamespace(); + QVERIFY(ns); + QCOMPARE(ns->memberCount(), 1U); + Template *templateClass = ns->memberAt(0)->asTemplate(); + + FindUsages findUsages(src, doc, snapshot); + findUsages(templateClass); + QCOMPARE(findUsages.usages().size(), 3); +} + QTEST_APPLESS_MAIN(tst_FindUsages) #include "tst_findusages.moc" -- cgit v1.2.1