Fixed #8558 (False portability positive caused by incorrect method resolution)
This commit is contained in:
parent
a27c88f99b
commit
36b6fb9f4d
|
@ -4310,7 +4310,7 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
|
||||||
|
|
||||||
// check if all arguments matched
|
// check if all arguments matched
|
||||||
if (same == hasToBe) {
|
if (same == hasToBe) {
|
||||||
if (constFallback)
|
if (constFallback || (!requireConst && func->isConst()))
|
||||||
fallback1Func = func;
|
fallback1Func = func;
|
||||||
else
|
else
|
||||||
return func;
|
return func;
|
||||||
|
|
|
@ -336,6 +336,7 @@ private:
|
||||||
TEST_CASE(findFunction18);
|
TEST_CASE(findFunction18);
|
||||||
TEST_CASE(findFunction19);
|
TEST_CASE(findFunction19);
|
||||||
TEST_CASE(findFunction20); // #8280
|
TEST_CASE(findFunction20); // #8280
|
||||||
|
TEST_CASE(findFunction21);
|
||||||
|
|
||||||
TEST_CASE(noexceptFunction1);
|
TEST_CASE(noexceptFunction1);
|
||||||
TEST_CASE(noexceptFunction2);
|
TEST_CASE(noexceptFunction2);
|
||||||
|
@ -5408,6 +5409,25 @@ private:
|
||||||
ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 12);
|
ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void findFunction21() { // # 8558
|
||||||
|
GET_SYMBOL_DB("struct foo {\n"
|
||||||
|
" int GetThing( ) const { return m_thing; }\n"
|
||||||
|
" int* GetThing( ) { return &m_thing; }\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"void f(foo *myFoo) {\n"
|
||||||
|
" int* myThing = myFoo->GetThing();\n"
|
||||||
|
"}");
|
||||||
|
|
||||||
|
ASSERT(db != nullptr);
|
||||||
|
|
||||||
|
const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "myFoo . GetThing ( ) ;");
|
||||||
|
|
||||||
|
const Function *f = tok1 && tok1->tokAt(2) ? tok1->tokAt(2)->function() : nullptr;
|
||||||
|
ASSERT(f != nullptr);
|
||||||
|
ASSERT_EQUALS(true, f && f->tokenDef->linenr() == 3);
|
||||||
|
}
|
||||||
|
|
||||||
#define FUNC(x) const Function *x = findFunctionByName(#x, &db->scopeList.front()); \
|
#define FUNC(x) const Function *x = findFunctionByName(#x, &db->scopeList.front()); \
|
||||||
ASSERT_EQUALS(true, x != nullptr); \
|
ASSERT_EQUALS(true, x != nullptr); \
|
||||||
if (x) ASSERT_EQUALS(true, x->isNoExcept());
|
if (x) ASSERT_EQUALS(true, x->isNoExcept());
|
||||||
|
|
Loading…
Reference in New Issue