From c51f44ce4c492abd4547cb64cf51a0353cd40e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 31 Jul 2019 18:24:15 +0200 Subject: [PATCH] SymbolDatabase: extend usage of ValueType::matchParameter for variable parameters --- lib/symboldatabase.cpp | 6 +++++- test/testsymboldatabase.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index f40758364..dec82d091 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -4047,6 +4047,10 @@ static void checkVariableCallMatch(const Variable* callarg, const Variable* func same++; return; } + if (res == ValueType::MatchResult::FALLBACK1) { + fallback1++; + return; + } bool ptrequals = callarg->isArrayOrPointer() == funcarg->isArrayOrPointer(); bool constEquals = !callarg->isArrayOrPointer() || ((callarg->typeStartToken()->strAt(-1) == "const") == (funcarg->typeStartToken()->strAt(-1) == "const")); @@ -5854,7 +5858,7 @@ ValueType::MatchResult ValueType::matchParameter(const ValueType *call, const Va return ValueType::MatchResult::NOMATCH; return ValueType::MatchResult::UNKNOWN; // TODO } - if (call->pointer > 0 && func->type != ValueType::Type::VOID && ((call->constness | func->constness) != func->constness)) + if (call->pointer > 0 && ((call->constness | func->constness) != func->constness)) return ValueType::MatchResult::NOMATCH; if (call->type != func->type) { if (call->type == ValueType::Type::VOID || func->type == ValueType::Type::VOID) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index f5dc7f534..efce7ebbd 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -5126,7 +5126,7 @@ private: ASSERT_EQUALS(true, f && f->function() && f->function()->tokenDef->linenr() == 4); f = Token::findsimplematch(tokenizer.tokens(), "foo ( & f ) ;"); - ASSERT_EQUALS(true, f && f->function() && f->function()->tokenDef->linenr() == 5); + ASSERT_EQUALS(true, f && f->function() == nullptr); f = Token::findsimplematch(tokenizer.tokens(), "foo ( ip ) ;"); ASSERT_EQUALS(true, f && f->function() && f->function()->tokenDef->linenr() == 4);