From b56c765a450d71ae3d2c922f49756f3d307e5335 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sat, 20 Aug 2016 07:43:15 +0200 Subject: [PATCH] Fixed #7703 ((debug) Executable scope 'foo' with unknown function.) --- lib/symboldatabase.cpp | 7 +++++++ test/testsymboldatabase.cpp | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 78620a27b..a2422c78a 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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% ,|)|[")) && diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index faabab85a..ede42cd95 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -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); \