diff --git a/lib/library.cpp b/lib/library.cpp index 2f7c6e0dc..d560f01fe 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -967,7 +967,15 @@ std::string Library::getFunctionName(const Token *ftok, bool &error) const continue; const std::vector &derivedFrom = scope->definedType->derivedFrom; for (const Type::BaseInfo & baseInfo : derivedFrom) { - const std::string name(baseInfo.name + "::" + ftok->str()); + std::string name; + const Token* tok = baseInfo.nameTok; // baseInfo.name still contains template parameters, but is missing namespaces + if (tok->str() == "::") + tok = tok->next(); + while (Token::Match(tok, "%name%|::")) { + name += tok->str(); + tok = tok->next(); + } + name += "::" + ftok->str(); if (functions.find(name) != functions.end() && matchArguments(ftok, name)) return name; } diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 90d87d37b..20254275d 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -2002,6 +2002,11 @@ private: "}\n", "test.cpp", &s); ASSERT_EQUALS("[test.cpp:5]: (information) --check-library: There is no matching configuration for function T::h()\n", errout.str()); + + check("struct S : std::vector {\n" + " void f(int i) { push_back(i); }\n" + "};\n", "test.cpp", &s); + ASSERT_EQUALS("", errout.str()); } void checkUseStandardLibrary1() {