diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 8c26d5996..18d323fd1 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5782,6 +5782,10 @@ ValueType::MatchResult ValueType::matchParameter(const ValueType *call, const Va if (call->typeScope != nullptr || func->typeScope != nullptr) return call->typeScope == func->typeScope ? ValueType::MatchResult::SAME : ValueType::MatchResult::NOMATCH; + if (call->container != nullptr || func->container != nullptr) + // TODO: verify the typename + return call->container == func->container ? ValueType::MatchResult::SAME : ValueType::MatchResult::NOMATCH; + if (func->type < ValueType::Type::VOID || func->type == ValueType::Type::UNKNOWN_INT) return ValueType::MatchResult::UNKNOWN; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index e82cf7d31..e9e21c082 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -343,6 +343,7 @@ private: TEST_CASE(findFunction24); // smart pointer TEST_CASE(findFunction25); // std::vector> TEST_CASE(findFunction26); // #8668 - pointer parameter in function call, const pointer function argument + TEST_CASE(findFunction27); TEST_CASE(valueTypeMatchParameter); // ValueType::matchParameter @@ -5532,6 +5533,18 @@ private: ASSERT(dostuff1->function() && dostuff1->function()->token && dostuff1->function()->token->linenr() == 1); } + void findFunction27() { + GET_SYMBOL_DB("void dostuff(std::vector v);\n" + "void f(std::vector v) {\n" + " dostuff(v);\n" + "}"); + (void)db; + const Token *dostuff = Token::findsimplematch(tokenizer.tokens(), "dostuff ( v ) ;"); + ASSERT(dostuff->function()); + ASSERT(dostuff->function() && dostuff->function()->tokenDef); + ASSERT(dostuff->function() && dostuff->function()->tokenDef && dostuff->function()->tokenDef->linenr() == 1); + } + void valueTypeMatchParameter() { ValueType vt_int(ValueType::Sign::SIGNED, ValueType::Type::INT, 0); ValueType vt_const_int(ValueType::Sign::SIGNED, ValueType::Type::INT, 0, 1);