More conservative fallback for function overload matching
This commit is contained in:
parent
4e28d40bf0
commit
3f1e2b4270
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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()); \
|
||||
|
|
Loading…
Reference in New Issue