diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 3d6972aa5..b3987f719 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1265,8 +1265,27 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Function } else if (tok->str() == "[") isArrayVar = true; + else if (tok->str() == "<") + { + int level = 1; + while (tok && tok->next()) + { + tok = tok->next(); + if (tok->str() == ">") + { + --level; + if (level == 0) + break; + } + else if (tok->str() == "<") + level++; + } + } tok = tok->next(); + + if (!tok) // something is wrong so just bail + return; } // check for argument with no name or missing varid diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index dd35a8a7b..7ed0b0db1 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -100,6 +100,8 @@ private: TEST_CASE(hasGlobalVariables1); TEST_CASE(hasGlobalVariables2); TEST_CASE(hasGlobalVariables3); + + TEST_CASE(functionArgs1); } void test_isVariableDeclarationCanHandleNull() @@ -604,6 +606,37 @@ private: } } } + + void check(const char code[]) + { + // Clear the error log + errout.str(""); + + // Check.. + Settings settings; + settings.debugwarnings = true; + + // Tokenize.. + Tokenizer tokenizer(&settings, this); + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); + tokenizer.simplifyTokenList(); + + // force symbol database creation + tokenizer.getSymbolDatabase(); + } + + void functionArgs1() + { + check("void f(std::vector, const std::vector & v) { }\n"); + + ASSERT_EQUALS("", errout.str()); + + check("void f(std::map > m) { }\n"); + + ASSERT_EQUALS("", errout.str()); + } + }; REGISTER_TEST(TestSymbolDatabase)