Fixed #7703 ((debug) Executable scope 'foo' with unknown function.)
This commit is contained in:
parent
f1b5ac30a7
commit
b56c765a45
|
@ -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% ,|)|[")) &&
|
||||
|
|
|
@ -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); \
|
||||
|
|
Loading…
Reference in New Issue