From 3ee9ab06b1e4a73bd74c5af9f359327db7cd4f79 Mon Sep 17 00:00:00 2001 From: chrchr Date: Thu, 29 Feb 2024 18:54:44 +0100 Subject: [PATCH] Fix checkLibraryFunction warning when deriving from std::vector --- lib/library.cpp | 2 ++ test/testfunctions.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib/library.cpp b/lib/library.cpp index 05d92c047f0..76b549e34f4 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -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; diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 6fdc2f42dc6..9e677690eda 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -2046,6 +2046,12 @@ class TestFunctions : public TestFixture { " return ::std::string(c);\n" "}\n", "test.cpp", &s); ASSERT_EQUALS("", errout.str()); + + check("template \n" + "struct S : public std::vector {\n" + " void resize(size_t n) { std::vector::resize(n); }\n" + "};\n", "test.cpp", &s); + ASSERT_EQUALS("", errout.str()); } void checkUseStandardLibrary1() {