diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index c5f65e08f..877cf7033 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1383,6 +1383,22 @@ static void createAstAtTokenInner(Token * const tok1, const Token *endToken, boo tok = createAstAtToken(tok, cpp); } } + else if (Token::simpleMatch(tok, "( * ) [")) { + bool hasAst = false; + for (const Token* tok2 = tok->linkAt(3); tok2 != tok; tok2 = tok2->previous()) { + if (tok2->astParent() || tok2->astOperand1() || tok2->astOperand2()) { + hasAst = true; + break; + } + } + if (!hasAst) { + Token *const startTok = tok = tok->tokAt(4); + const Token* const endtok = startTok->linkAt(-1); + AST_state state(cpp); + compileExpression(tok, state); + createAstAtTokenInner(startTok, endtok, cpp); + } + } } } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 099ec4f8d..141251a42 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6361,6 +6361,8 @@ private: ASSERT_EQUALS("esi.!(=", testAst("E e = (E)!s->i;")); // #10882 + ASSERT_EQUALS("xp(= 12>34:?", testAst("x = ( const char ( * ) [ 1 > 2 ? 3 : 4 ] ) p ;")); + // not cast ASSERT_EQUALS("AB||", testAst("(A)||(B)")); ASSERT_EQUALS("abc[1&=", testAst("a = (b[c]) & 1;"));