diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 84299abde..ef0737d38 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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 diff --git a/test/testclass.cpp b/test/testclass.cpp index b1b63f790..3c9adee8a 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -7678,6 +7678,15 @@ private: " void f(char c, std::vector 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() {