More conservative fallback for function overload matching

This commit is contained in:
PKEuS 2017-02-24 20:56:47 +01:00
parent 4e28d40bf0
commit 3f1e2b4270
2 changed files with 6 additions and 3 deletions

View File

@ -3900,10 +3900,9 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
++i;
}
// no exact match so just return first function found
if (!matches.empty()) {
// no exact match, but only one candidate left
if (matches.size() == 1)
return matches[0];
}
return nullptr;
}

View File

@ -3495,12 +3495,16 @@ private:
"void foo(long long a) { }\n"
"void foo() {\n"
" foo(0);\n"
" foo(bar());\n"
"}");
ASSERT_EQUALS("", errout.str());
const Token *f = Token::findsimplematch(tokenizer.tokens(), "foo ( 0 ) ;");
ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 2);
f = Token::findsimplematch(tokenizer.tokens(), "foo ( bar ( ) ) ;");
ASSERT_EQUALS(true, db && f && f->function() == nullptr);
}
#define FUNC(x) const Function *x = findFunctionByName(#x, &db->scopeList.front()); \