Fixed #8017 (AST: wrong ast for extra comma 's={1,}')

This commit is contained in:
Daniel Marjamäki 2017-04-22 11:23:11 +02:00
parent 7140bae226
commit 1039c710e4
2 changed files with 5 additions and 1 deletions

View File

@ -994,7 +994,10 @@ static void compileComma(Token *&tok, AST_state& state)
compileAssignTernary(tok, state);
while (tok) {
if (tok->str() == ",") {
compileBinOp(tok, state, compileAssignTernary);
if (Token::simpleMatch(tok, ", }"))
tok = tok->next();
else
compileBinOp(tok, state, compileAssignTernary);
} else break;
}
}

View File

@ -8077,6 +8077,7 @@ private:
ASSERT_EQUALS("tset{=", testAst("struct cgroup_taskset tset = {};"));
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
// struct initialization hang
ASSERT_EQUALS("sbar.1{,{(={= fcmd( forfieldfield++;;(",