summaryrefslogtreecommitdiff
path: root/tests/auto/cplusplus/findusages/tst_findusages.cpp
diff options
context:
space:
mode:
authorPrzemyslaw Gorszkowski <pgorszkowski@gmail.com>2013-04-02 23:04:12 +0200
committerErik Verbruggen <erik.verbruggen@digia.com>2013-04-09 11:23:14 +0200
commit7c74482ad361ee81f87c8ed039b789807934f0e7 (patch)
tree27d26259d19396ec7a0ccb18dd5510bfc0445626 /tests/auto/cplusplus/findusages/tst_findusages.cpp
parentbe085863fcc555ca9fb6a18d38f5c36a4b0ea690 (diff)
downloadqt-creator-7c74482ad361ee81f87c8ed039b789807934f0e7.tar.gz
C++: fixed operator* for nested class of enclosing template class
Fixed: * highlighting * follow symbol * find usage Task-number: QTCREATORBUG-9006 Change-Id: I34a42f8665335857f41290217e7265e8a752455b Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Sergey Shambir <sergey.shambir.auto@gmail.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'tests/auto/cplusplus/findusages/tst_findusages.cpp')
-rw-r--r--tests/auto/cplusplus/findusages/tst_findusages.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/cplusplus/findusages/tst_findusages.cpp b/tests/auto/cplusplus/findusages/tst_findusages.cpp
index 339d852ca0..f2098ab838 100644
--- a/tests/auto/cplusplus/findusages/tst_findusages.cpp
+++ b/tests/auto/cplusplus/findusages/tst_findusages.cpp
@@ -94,6 +94,7 @@ private Q_SLOTS:
// templates
void instantiateTemplateWithNestedClass();
+ void operatorAsteriskOfNestedClassOfTemplateClass_QTCREATORBUG9006();
};
void tst_FindUsages::inlineMethod()
@@ -444,5 +445,50 @@ void tst_FindUsages::instantiateTemplateWithNestedClass()
QCOMPARE(findUsages.usages().size(), 2);
}
+void tst_FindUsages::operatorAsteriskOfNestedClassOfTemplateClass_QTCREATORBUG9006()
+{
+ const QByteArray src = "\n"
+ "struct Foo { int foo; };\n"
+ "\n"
+ "template<class T>\n"
+ "struct Outer\n"
+ "{\n"
+ " struct Nested\n"
+ " {\n"
+ " const T &operator*() { return t; }\n"
+ " T t;\n"
+ " };\n"
+ "};\n"
+ "\n"
+ "void bug()\n"
+ "{\n"
+ " Outer<Foo>::Nested nested;\n"
+ " (*nested).foo;\n"
+ "}\n"
+ ;
+
+ Document::Ptr doc = Document::create("operatorAsteriskOfNestedClassOfTemplateClass_QTCREATORBUG9006");
+ doc->setUtf8Source(src);
+ doc->parse();
+ doc->check();
+
+ QVERIFY(doc->diagnosticMessages().isEmpty());
+ QCOMPARE(doc->globalSymbolCount(), 3U);
+
+ Snapshot snapshot;
+ snapshot.insert(doc);
+
+ Class *classFoo = doc->globalSymbolAt(0)->asClass();
+ QVERIFY(classFoo);
+ QCOMPARE(classFoo->memberCount(), 1U);
+ Declaration *fooDeclaration = classFoo->memberAt(0)->asDeclaration();
+ QVERIFY(fooDeclaration);
+ QCOMPARE(fooDeclaration->name()->identifier()->chars(), "foo");
+
+ FindUsages findUsages(src, doc, snapshot);
+ findUsages(fooDeclaration);
+ QCOMPARE(findUsages.usages().size(), 2);
+}
+
QTEST_APPLESS_MAIN(tst_FindUsages)
#include "tst_findusages.moc"