Fixed #7703 ((debug) Executable scope 'foo' with unknown function.)

This commit is contained in:
Robert Reif 2016-08-20 07:43:15 +02:00 committed by Daniel Marjamäki
parent f1b5ac30a7
commit b56c765a45
2 changed files with 18 additions and 0 deletions

View File

@ -1751,6 +1751,13 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
else if (second->str() == ")")
break;
// const after *
else if (first->next()->str() == "*" && first->strAt(2) != "const" &&
second->next()->str() == "*" && second->strAt(2) == "const") {
first = first->next();
second = second->tokAt(2);
}
// variable names are different
else if ((Token::Match(first->next(), "%name% ,|)|=|[") &&
Token::Match(second->next(), "%name% ,|)|[")) &&

View File

@ -277,6 +277,7 @@ private:
TEST_CASE(findFunction6);
TEST_CASE(findFunction7); // #6700
TEST_CASE(findFunction8);
TEST_CASE(findFunction9);
TEST_CASE(noexceptFunction1);
TEST_CASE(noexceptFunction2);
@ -3393,6 +3394,16 @@ private:
ASSERT_EQUALS(true, db && f && f->tokAt(2)->function() && f->tokAt(2)->function()->tokenDef->linenr() == 13 && f->tokAt(2)->function()->token->linenr() == 20);
}
void findFunction9() {
GET_SYMBOL_DB("struct Fred {\n"
" void foo(const int * p);\n"
"};\n"
"void Fred::foo(const int * const p) { }");
ASSERT_EQUALS("", errout.str());
const Token *f = Token::findsimplematch(tokenizer.tokens(), "foo ( const int * const p ) {");
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); \