AST: Fix AST for array size calculation in cast (char (*)[...])
This commit is contained in:
parent
4257f9d46a
commit
72ba85a2fc
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;"));
|
||||
|
|
Loading…
Reference in New Issue