ValueType::matchParameter: Fix matching of char** and void*

This commit is contained in:
Daniel Marjamäki 2019-07-31 16:23:50 +02:00
parent 549452b7b9
commit 1eb5f2266c
2 changed files with 5 additions and 0 deletions

View File

@ -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())

View File

@ -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()); \