Fix #11764 checkLibraryFunction/NoReturn when inheriting from container
This commit is contained in:
parent
09cd3a8269
commit
0afc5aba78
|
@ -967,7 +967,15 @@ std::string Library::getFunctionName(const Token *ftok, bool &error) const
|
||||||
continue;
|
continue;
|
||||||
const std::vector<Type::BaseInfo> &derivedFrom = scope->definedType->derivedFrom;
|
const std::vector<Type::BaseInfo> &derivedFrom = scope->definedType->derivedFrom;
|
||||||
for (const Type::BaseInfo & baseInfo : 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))
|
if (functions.find(name) != functions.end() && matchArguments(ftok, name))
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2002,6 +2002,11 @@ private:
|
||||||
"}\n", "test.cpp", &s);
|
"}\n", "test.cpp", &s);
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (information) --check-library: There is no matching configuration for function T::h()\n",
|
ASSERT_EQUALS("[test.cpp:5]: (information) --check-library: There is no matching configuration for function T::h()\n",
|
||||||
errout.str());
|
errout.str());
|
||||||
|
|
||||||
|
check("struct S : std::vector<int> {\n"
|
||||||
|
" void f(int i) { push_back(i); }\n"
|
||||||
|
"};\n", "test.cpp", &s);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkUseStandardLibrary1() {
|
void checkUseStandardLibrary1() {
|
||||||
|
|
Loading…
Reference in New Issue