Fix #10920 FP missingOverride with friend (#3955)

This commit is contained in:
chrchr-github 2022-03-28 22:44:04 +02:00 committed by GitHub
parent 49147f95fe
commit 81bcbfa7fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -1754,7 +1754,8 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
if (Token::Match(tok1, "%name%")) {
if (tok1->str() == "return")
return false;
tok1 = tok1->previous();
if (tok1->str() != "friend")
tok1 = tok1->previous();
}
// skip over qualification

View File

@ -7678,6 +7678,15 @@ private:
" void f(char c, std::vector<int> w = {});\n"
"};\n");
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:5]: (style) The function 'f' overrides a function in a base class but is not marked with a 'override' specifier.\n", "", errout.str());
checkOverride("struct T {};\n" // #10920
"struct B {\n"
" virtual T f() = 0;\n"
"};\n"
"struct D : B {\n"
" friend T f();\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void overrideCVRefQualifiers() {