Skip to content

Commit d9f72d5

Browse files
committed
AST: Handle 'x = { [ID] = 1, .. }' when ID is unexpanded macro
1 parent bdf16b1 commit d9f72d5

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/tokenlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ static void compileTerm(Token *&tok, AST_state& state)
590590
tok->astOperand1(tok->next());
591591
tok = tok->tokAt(2);
592592
}
593-
if (state.inArrayAssignment && Token::Match(tok->previous(), "[{,] [ %num% ]")) {
593+
if (state.inArrayAssignment && Token::Match(tok->previous(), "[{,] [ %num%|%name% ]")) {
594594
state.op.push(tok);
595595
tok->astOperand1(tok->next());
596596
tok = tok->tokAt(3);

test/testtokenize.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8078,6 +8078,7 @@ class TestTokenizer : public TestFixture {
80788078
ASSERT_EQUALS("s1a&,{2b&,{,{=", testAst("s = { {1, &a}, {2, &b} };"));
80798079
ASSERT_EQUALS("s0[L.2[x={=", testAst("s = { [0].L[2] = x};"));
80808080
ASSERT_EQUALS("ac.0={(=", testAst("a = (b){.c=0,};")); // <- useless comma
8081+
ASSERT_EQUALS("xB[1y.z.1={(&=,{={=", testAst("x = { [B] = {1, .y = &(struct s) { .z=1 } } };"));
80818082

80828083
// struct initialization hang
80838084
ASSERT_EQUALS("sbar.1{,{(={= fcmd( forfieldfield++;;(",

0 commit comments

Comments
 (0)