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

This commit is contained in:
Robert Reif 2016-08-20 17:56:48 +02:00 committed by Daniel Marjamäki
parent 4745d844ad
commit 1dd1f6dd6a
2 changed files with 27 additions and 2 deletions

View File

@ -1751,6 +1751,17 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
else if (second->str() == ")")
break;
// ckeck for type * x == type x[]
else if (Token::Match(first->next(), "* %name%| ,|)|=") &&
Token::Match(second->next(), "%name%| [ ] ,|)")) {
do {
first = first->next();
} while (!Token::Match(first->next(), ",|)"));
do {
second = second->next();
} while (!Token::Match(second->next(), ",|)"));
}
// const after *
else if (first->next()->str() == "*" && first->strAt(2) != "const" &&
second->next()->str() == "*" && second->strAt(2) == "const") {
@ -1817,9 +1828,11 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
second = second->next();
// skip const on type passed by value
if (Token::Match(first, "const %type% %name%|,|)"))
if (Token::Match(first, "const %type% %name%|,|)") &&
!Token::Match(first, "const %type% %name%| ["))
first = first->next();
if (Token::Match(second, "const %type% %name%|,|)"))
if (Token::Match(second, "const %type% %name%|,|)") &&
!Token::Match(second, "const %type% %name%| ["))
second = second->next();
}

View File

@ -278,6 +278,7 @@ private:
TEST_CASE(findFunction7); // #6700
TEST_CASE(findFunction8);
TEST_CASE(findFunction9);
TEST_CASE(findFunction10); // #7673
TEST_CASE(noexceptFunction1);
TEST_CASE(noexceptFunction2);
@ -3405,6 +3406,17 @@ private:
ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 2);
}
void findFunction10() { // #7673
GET_SYMBOL_DB("struct Fred {\n"
" void foo(const int * p);\n"
"};\n"
"void Fred::foo(const int p []) { }");
ASSERT_EQUALS("", errout.str());
const Token *f = Token::findsimplematch(tokenizer.tokens(), "foo ( const int 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); \
if (x) ASSERT_EQUALS(true, x->isNoExcept());