Skip to content

Commit

Permalink
Fix checkLibraryFunction warning when deriving from std::vector (#6071)
Browse files Browse the repository at this point in the history
Inspired by #4834
  • Loading branch information
chrchr-github authored Feb 29, 2024
1 parent f2e98f2 commit e156fbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,8 @@ std::string Library::getFunctionName(const Token *ftok, bool &error) const
return "";
}
if (ftok->isName()) {
if (Token::simpleMatch(ftok->astParent(), "::"))
return ftok->str();
for (const Scope *scope = ftok->scope(); scope; scope = scope->nestedIn) {
if (!scope->isClassOrStruct())
continue;
Expand Down
6 changes: 6 additions & 0 deletions test/testfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2046,6 +2046,12 @@ class TestFunctions : public TestFixture {
" return ::std::string(c);\n"
"}\n", "test.cpp", &s);
ASSERT_EQUALS("", errout.str());

check("template <typename T>\n"
"struct S : public std::vector<T> {\n"
" void resize(size_t n) { std::vector<T>::resize(n); }\n"
"};\n", "test.cpp", &s);
ASSERT_EQUALS("", errout.str());
}

void checkUseStandardLibrary1() {
Expand Down

0 comments on commit e156fbf

Please sign in to comment.