diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 276f75c08..264591957 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2692,6 +2692,7 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se (Token::Match(second->next(), "%name% <") && Token::Match(second->linkAt(1), "> :: %name%"))) && ((second->next()->str() == scope->className) || + (scope->nestedIn && second->next()->str() == scope->nestedIn->className) || (scope->definedType && scope->definedType->isDerivedFrom(second->next()->str()))) && (first->next()->str() == second->strAt(3))) { if (Token::Match(second->next(), "%name% <")) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index a929c934a..fac90ba2b 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -357,6 +357,7 @@ private: TEST_CASE(symboldatabase96); // #10126 TEST_CASE(symboldatabase97); // #10598 - final class TEST_CASE(symboldatabase98); // #10451 + TEST_CASE(symboldatabase100); // #10174 TEST_CASE(createSymbolDatabaseFindAllScopes1); TEST_CASE(createSymbolDatabaseFindAllScopes2); @@ -4879,6 +4880,23 @@ private: } } + void symboldatabase100() { // #10174 + GET_SYMBOL_DB("namespace N {\n" + " struct S {};\n" + " struct T { void f(S s); };\n" + " void T::f(N::S s) {}\n" + "}\n"); + ASSERT(db); + ASSERT_EQUALS(1, db->functionScopes.size()); + auto it = std::find_if(db->scopeList.begin(), db->scopeList.end(), [](const Scope& s) { + return s.className == "T"; + }); + ASSERT(it != db->scopeList.end()); + const Function* function = findFunctionByName("f", &*it); + ASSERT(function && function->token->str() == "f"); + ASSERT(function->hasBody()); + } + void createSymbolDatabaseFindAllScopes1() { GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }"); ASSERT(db->scopeList.size() == 3);