diff --git a/src/plugins/cpptools/cppchecksymbols.cpp b/src/plugins/cpptools/cppchecksymbols.cpp index 6ae41a37842a118bfd018e1b883c166c795a1dd4..2b48ae1e115bb6309e6cc904f424de1d844b5c15 100644 --- a/src/plugins/cpptools/cppchecksymbols.cpp +++ b/src/plugins/cpptools/cppchecksymbols.cpp @@ -594,6 +594,8 @@ bool CheckSymbols::visit(CallAST *ast) if (QualifiedNameAST *q = memberName->asQualifiedName()) { checkNestedName(q); memberName = q->unqualified_name; + } else if (TemplateIdAST *tId = memberName->asTemplateId()) { + accept(tId->template_argument_list); } if (!maybeAddFunction(candidates, memberName, argumentCount) @@ -611,6 +613,8 @@ bool CheckSymbols::visit(CallAST *ast) if (QualifiedNameAST *q = exprName->asQualifiedName()) { checkNestedName(q); exprName = q->unqualified_name; + } else if (TemplateIdAST *tId = exprName->asTemplateId()) { + accept(tId->template_argument_list); } const QList<LookupItem> candidates = diff --git a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp index e8b8e98f54e01029874a9e4183195c89e9450aa6..b5ee70b5239e6921eed96782b601923eaa4fa436 100644 --- a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp +++ b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp @@ -184,6 +184,7 @@ private slots: void test_checksymbols_QTCREATORBUG8890_danglingPointer(); void test_checksymbols_QTCREATORBUG8974_danglingPointer(); void operatorAsteriskOfNestedClassOfTemplateClass_QTCREATORBUG9006(); + void test_checksymbols_templated_functions(); }; void tst_CheckSymbols::test_checksymbols_TypeUse() @@ -1387,7 +1388,34 @@ void tst_CheckSymbols::operatorAsteriskOfNestedClassOfTemplateClass_QTCREATORBUG ; TestData::check(source, expectedUses); +} + +void tst_CheckSymbols::test_checksymbols_templated_functions() +{ + const QByteArray source = + "struct D {};\n" // line 1 + "struct A {\n" // line 2 + " template<typename T> int B();\n" // line 3 + " void C() {\n" // line 4 + " B<D>();\n" // line 5 + " this->B<D>();\n" // line 6 + " }\n" // line 7 + "};\n" // line 8 + ; + const QList<Use> expectedUses = QList<Use>() + << Use(1, 8, 1, SemanticInfo::TypeUse) + << Use(2, 8, 1, SemanticInfo::TypeUse) + << Use(3, 23, 1, SemanticInfo::TypeUse) + << Use(3, 30, 1, SemanticInfo::FunctionUse) + << Use(4, 10, 1, SemanticInfo::FunctionUse) + << Use(5, 9, 1, SemanticInfo::FunctionUse) + << Use(5, 11, 1, SemanticInfo::TypeUse) + << Use(6, 15, 1, SemanticInfo::FunctionUse) + << Use(6, 17, 1, SemanticInfo::TypeUse) + ; + + TestData::check(source, expectedUses); } QTEST_APPLESS_MAIN(tst_CheckSymbols)