Fix #10265 FP unused private method (#4015)

This commit is contained in:
chrchr-github 2022-04-13 14:49:28 +02:00 committed by GitHub
parent da1e2b22be
commit 938517b80a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -581,7 +581,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
}
// friend class declaration?
else if (mTokenizer->isCPP() && tok->isKeyword() && Token::Match(tok, "friend class| ::| %any% ;|::")) {
else if (mTokenizer->isCPP() && tok->isKeyword() && Token::Match(tok, "friend class|struct| ::| %any% ;|::")) {
Type::FriendInfo friendInfo;
// save the name start

View File

@ -583,6 +583,20 @@ private:
" void f() { }\n"
"};");
ASSERT_EQUALS("[test.cpp:5]: (style) Unused private function: 'Foo::f'\n", errout.str());
check("struct F;\n" // #10265
"struct S {\n"
" int i{};\n"
" friend struct F;\n"
"private:\n"
" int f() const { return i; }\n"
"};\n"
"struct F {\n"
" bool operator()(const S& lhs, const S& rhs) const {\n"
" return lhs.f() < rhs.f();\n"
" }\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void borland1() {