diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index f98335badb7..2ad9e01a462 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1837,7 +1837,7 @@ static Token * createAstAtToken(Token *tok) } typetok = typetok->next(); } - if (Token::Match(typetok, "%var% [={]")) + if (Token::Match(typetok, "%var% =|{|[")) tok = typetok; // Do not create AST for function declaration diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 5f4d59503e2..19a4dfa261c 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -440,6 +440,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(astfuncdecl); TEST_CASE(astarrayinit); TEST_CASE(astbracedinit); + TEST_CASE(astarrayofptrs); TEST_CASE(startOfExecutableScope); @@ -7543,6 +7544,11 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("anullptr{", testAst("int *a { nullptr };", AstStyle::Simple, ListSimplification::Full)); } + void astarrayofptrs() { + ASSERT_EQUALS("a1[", testAst("int *a[1];", AstStyle::Simple, ListSimplification::Full)); + ASSERT_EQUALS("a1[", testAst("int **a[1];", AstStyle::Simple, ListSimplification::Full)); + } + #define isStartOfExecutableScope(offset, code) isStartOfExecutableScope_(offset, code, __FILE__, __LINE__) template bool isStartOfExecutableScope_(int offset, const char (&code)[size], const char* file, int line) {