diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 6c2d8ac11..ead1390b5 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2327,6 +2327,12 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map= 2 && tok2 && tok2->str() == "(") { + const Token *tok3 = tok2->next(); + if (tok3->str() != "new" && tok3->str() != "sizeof" && setVarIdParseDeclaration(&tok3, variableId, executableScope, cpp)) + return false; + } + return bool(typeCount >= 2 && tok2 && Token::Match(tok2->tokAt(-2), "!!:: %type%")); } diff --git a/test/testvarid.cpp b/test/testvarid.cpp index b6b75e18f..e52456734 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -1171,6 +1171,13 @@ private: "1: void f ( struct foobar ) ;\n"); ASSERT_EQUALS(expected, actual); } + + { + const std::string actual = tokenize("bool f(X x, int=3);", false, "test.cpp"); + const std::string expected("\n\n##file 0\n" + "1: bool f ( X x@1 , int = 3 ) ;\n"); + ASSERT_EQUALS(expected, actual); + } } void varid_sizeof() {