From 0afc5aba783beac85a947ee6c8b793a331ce0d19 Mon Sep 17 00:00:00 2001 From: chrchr Date: Tue, 13 Jun 2023 15:04:25 +0200 Subject: [PATCH] Fix #11764 checkLibraryFunction/NoReturn when inheriting from container --- lib/library.cpp | 10 +++++++++- test/testfunctions.cpp | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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() {