AST: Handle 'x = { [ID] = 1, .. }' when ID is unexpanded macro

This commit is contained in:
Daniel Marjamäki 2017-04-26 22:35:04 +02:00
parent bdf16b1157
commit d9f72d5f8c
2 changed files with 2 additions and 1 deletions

View File

@ -590,7 +590,7 @@ static void compileTerm(Token *&tok, AST_state& state)
tok->astOperand1(tok->next());
tok = tok->tokAt(2);
}
if (state.inArrayAssignment && Token::Match(tok->previous(), "[{,] [ %num% ]")) {
if (state.inArrayAssignment && Token::Match(tok->previous(), "[{,] [ %num%|%name% ]")) {
state.op.push(tok);
tok->astOperand1(tok->next());
tok = tok->tokAt(3);

View File

@ -8078,6 +8078,7 @@ private:
ASSERT_EQUALS("s1a&,{2b&,{,{=", testAst("s = { {1, &a}, {2, &b} };"));
ASSERT_EQUALS("s0[L.2[x={=", testAst("s = { [0].L[2] = x};"));
ASSERT_EQUALS("ac.0={(=", testAst("a = (b){.c=0,};")); // <- useless comma
ASSERT_EQUALS("xB[1y.z.1={(&=,{={=", testAst("x = { [B] = {1, .y = &(struct s) { .z=1 } } };"));
// struct initialization hang
ASSERT_EQUALS("sbar.1{,{(={= fcmd( forfieldfield++;;(",