diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 230b50bed31..1e1430649ae 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1100,16 +1100,18 @@ void SymbolDatabase::createSymbolDatabaseSetFunctionPointers(bool firstPass) if (tok->next()->str() == ">" && !tok->next()->link()) continue; + bool isTemplateArg = false; if (tok->next()->str() != "(") { const Token *start = tok; while (Token::Match(start->tokAt(-2), "%name% ::")) start = start->tokAt(-2); if (!Token::Match(start->previous(), "[(,<=]") && !Token::Match(start->tokAt(-2), "[(,<=] &") && !Token::Match(start, "%name% ;")) continue; + isTemplateArg = Token::simpleMatch(start->previous(), "<") || Token::simpleMatch(start->tokAt(-2), "<"); } const Function *function = findFunction(tok); - if (!function) + if (!function || (isTemplateArg && function->isConstructor())) continue; const_cast(tok)->function(function); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 9b144fcb6d5..615814d3b90 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -443,6 +443,7 @@ class TestSymbolDatabase : public TestFixture { TEST_CASE(findFunction44); // #11182 TEST_CASE(findFunction45); TEST_CASE(findFunction46); + TEST_CASE(findFunction47); TEST_CASE(findFunctionContainer); TEST_CASE(findFunctionExternC); TEST_CASE(findFunctionGlobalScope); // ::foo @@ -7149,6 +7150,18 @@ class TestSymbolDatabase : public TestFixture { ASSERT_EQUALS(3, functok->function()->tokenDef->linenr()); } + void findFunction47() { + GET_SYMBOL_DB("struct S {\n" + " S() {}\n" + " std::list l;\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); + const Token* typeTok = Token::findsimplematch(tokenizer.tokens(), "S >"); + ASSERT(typeTok && typeTok->type()); + ASSERT(typeTok->type()->name() == "S"); + ASSERT_EQUALS(1, typeTok->type()->classDef->linenr()); + } + void findFunctionContainer() { { GET_SYMBOL_DB("void dostuff(std::vector v);\n"