Fixed matching long long overload to function call f(0)

This commit is contained in:
PKEuS 2017-02-24 20:33:52 +01:00
parent de86d40c97
commit 4e28d40bf0
2 changed files with 15 additions and 4 deletions

View File

@ -3836,10 +3836,7 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
same++;
}
} else {
if (funcarg->typeStartToken()->str() == "int" &&
!funcarg->typeStartToken()->isUnsigned()) {
same++;
} else if (Token::Match(funcarg->typeStartToken(), "char|short|int")) {
if (Token::Match(funcarg->typeStartToken(), "char|short|int|long")) {
same++;
}
}

View File

@ -280,6 +280,7 @@ private:
TEST_CASE(findFunction9);
TEST_CASE(findFunction10); // #7673
TEST_CASE(findFunction11);
TEST_CASE(findFunction12);
TEST_CASE(noexceptFunction1);
TEST_CASE(noexceptFunction2);
@ -3489,6 +3490,19 @@ private:
ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 4);
}
void findFunction12() {
GET_SYMBOL_DB("void foo(std::string a) { }\n"
"void foo(long long a) { }\n"
"void foo() {\n"
" foo(0);\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);
}
#define FUNC(x) const Function *x = findFunctionByName(#x, &db->scopeList.front()); \
ASSERT_EQUALS(true, x != nullptr); \
if (x) ASSERT_EQUALS(true, x->isNoExcept());