Skip to content

Commit e156fbf

Browse files
Fix checkLibraryFunction warning when deriving from std::vector (#6071)
Inspired by #4834
1 parent f2e98f2 commit e156fbf

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/library.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,8 @@ std::string Library::getFunctionName(const Token *ftok, bool &error) const
972972
return "";
973973
}
974974
if (ftok->isName()) {
975+
if (Token::simpleMatch(ftok->astParent(), "::"))
976+
return ftok->str();
975977
for (const Scope *scope = ftok->scope(); scope; scope = scope->nestedIn) {
976978
if (!scope->isClassOrStruct())
977979
continue;

test/testfunctions.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,6 +2046,12 @@ class TestFunctions : public TestFixture {
20462046
" return ::std::string(c);\n"
20472047
"}\n", "test.cpp", &s);
20482048
ASSERT_EQUALS("", errout.str());
2049+
2050+
check("template <typename T>\n"
2051+
"struct S : public std::vector<T> {\n"
2052+
" void resize(size_t n) { std::vector<T>::resize(n); }\n"
2053+
"};\n", "test.cpp", &s);
2054+
ASSERT_EQUALS("", errout.str());
20492055
}
20502056

20512057
void checkUseStandardLibrary1() {

0 commit comments

Comments
 (0)