diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index f64caa82e27..ff1bd88c38f 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -7686,7 +7686,7 @@ ValueType::MatchResult ValueType::matchParameter(const ValueType *call, const Va } if (call->typeScope != nullptr || func->typeScope != nullptr) { - if (call->typeScope != func->typeScope) + if (call->typeScope != func->typeScope && !(call->typeScope->definedType && call->typeScope->definedType->isDerivedFrom(func->typeScope->className))) return ValueType::MatchResult::NOMATCH; } diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index e558e4d3a36..62f0e4a6963 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -441,6 +441,7 @@ class TestSymbolDatabase : public TestFixture { TEST_CASE(findFunction46); TEST_CASE(findFunction47); TEST_CASE(findFunction48); + TEST_CASE(findFunction49); // #11888 TEST_CASE(findFunctionContainer); TEST_CASE(findFunctionExternC); TEST_CASE(findFunctionGlobalScope); // ::foo @@ -7286,6 +7287,22 @@ class TestSymbolDatabase : public TestFixture { ASSERT_EQUALS(1, typeTok->type()->classDef->linenr()); } + void findFunction49() { + GET_SYMBOL_DB("struct B {};\n" + "struct D : B {};\n" + "void f(bool = false, bool = true);\n" + "void f(B*, bool, bool = true);\n" + "void g() {\n" + " D d;\n" + " f(&d, true);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + const Token* ftok = Token::findsimplematch(tokenizer.tokens(), "f ( &"); + ASSERT(ftok && ftok->function()); + ASSERT(ftok->function()->name() == "f"); + ASSERT_EQUALS(4, ftok->function()->tokenDef->linenr()); + } + void findFunctionContainer() { { GET_SYMBOL_DB("void dostuff(std::vector v);\n"