diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 3f925c242..055df06a3 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1725,7 +1725,7 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se return !first && !second; } } else if (!first) { // End of argument list (first) - return second->next() && second->next()->str() == ")"; + return !second->nextArgument(); // End of argument list (second) } } else if (second->next()->str() == "=") { second = second->nextArgument(); @@ -1767,8 +1767,8 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se break; // variable names are different - else if ((Token::Match(first->next(), "%name% ,|)|=") && - Token::Match(second->next(), "%name% ,|)")) && + else if ((Token::Match(first->next(), "%name% ,|)|=|[") && + Token::Match(second->next(), "%name% ,|)|[")) && (first->next()->str() != second->next()->str())) { // skip variable names first = first->next(); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index b8b55172a..d862f0b4a 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -187,6 +187,8 @@ private: TEST_CASE(functionArgs7); // #7652 TEST_CASE(functionArgs8); // #7653 TEST_CASE(functionArgs9); // #7657 + TEST_CASE(functionArgs10); + TEST_CASE(functionArgs11); TEST_CASE(namespaces1); TEST_CASE(namespaces2); @@ -1755,6 +1757,54 @@ private: } } + void functionArgs10() { + GET_SYMBOL_DB("class Fred {\n" + "public:\n" + " Fred(Whitespace = PRESERVE_WHITESPACE);\n" + "};\n" + "Fred::Fred(Whitespace whitespace) { }"); + ASSERT_EQUALS(true, db != nullptr); + if (db) { + ASSERT_EQUALS(3, db->scopeList.size()); + if (db->scopeList.size() == 3) { + std::list::const_iterator scope = db->scopeList.begin(); + ++scope; + ASSERT_EQUALS((unsigned int)Scope::eClass, (unsigned int)scope->type); + ASSERT_EQUALS(1, scope->functionList.size()); + ASSERT(scope->functionList.begin()->functionScope != nullptr); + if (scope->functionList.begin()->functionScope) { + const Scope * functionScope = scope->functionList.begin()->functionScope; + ++scope; + ASSERT(functionScope == &*scope); + } + } + } + } + + void functionArgs11() { + GET_SYMBOL_DB("class Fred {\n" + "public:\n" + " void foo(char a[16]);\n" + "};\n" + "void Fred::foo(char b[16]) { }"); + ASSERT_EQUALS(true, db != nullptr); + if (db) { + ASSERT_EQUALS(3, db->scopeList.size()); + if (db->scopeList.size() == 3) { + std::list::const_iterator scope = db->scopeList.begin(); + ++scope; + ASSERT_EQUALS((unsigned int)Scope::eClass, (unsigned int)scope->type); + ASSERT_EQUALS(1, scope->functionList.size()); + ASSERT(scope->functionList.begin()->functionScope != nullptr); + if (scope->functionList.begin()->functionScope) { + const Scope * functionScope = scope->functionList.begin()->functionScope; + ++scope; + ASSERT(functionScope == &*scope); + } + } + } + } + void namespaces1() { GET_SYMBOL_DB("namespace fred {\n" " namespace barney {\n"