From 1eb5f2266c7730faa8ba9c601c6e2f5b761b5bba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 31 Jul 2019 16:23:50 +0200 Subject: [PATCH] ValueType::matchParameter: Fix matching of char** and void* --- lib/symboldatabase.cpp | 2 ++ test/testsymboldatabase.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index bac36db00..f40758364 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5846,6 +5846,8 @@ ValueType::MatchResult ValueType::matchParameter(const ValueType *call, const Va if (!call || !func) return ValueType::MatchResult::UNKNOWN; if (call->pointer != func->pointer) { + if (call->pointer > 1 && func->pointer == 1 && func->type == ValueType::Type::VOID) + return ValueType::MatchResult::FALLBACK1; if (call->pointer < func->pointer && !call->isIntegral()) return ValueType::MatchResult::NOMATCH; if (func->pointer < call->pointer && !func->isIntegral()) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 4ee018a54..f5dc7f534 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -5544,6 +5544,9 @@ private: ValueType vt_int_pointer(ValueType::Sign::SIGNED, ValueType::Type::INT, 1); // not compatible ASSERT_EQUALS((int)ValueType::MatchResult::FALLBACK1, (int)ValueType::matchParameter(&vt_char_pointer, &vt_void_pointer)); ASSERT_EQUALS((int)ValueType::MatchResult::NOMATCH, (int)ValueType::matchParameter(&vt_char_pointer, &vt_int_pointer)); + + ValueType vt_char_pointer2(ValueType::Sign::SIGNED, ValueType::Type::CHAR, 2); + ASSERT_EQUALS((int)ValueType::MatchResult::FALLBACK1, (int)ValueType::matchParameter(&vt_char_pointer2, &vt_void_pointer)); } #define FUNC(x) const Function *x = findFunctionByName(#x, &db->scopeList.front()); \