AST: improved handling for struct initialization 's = { [0] = 123 }'
This commit is contained in:
parent
d92c529aa6
commit
ffeadbdde4
|
@ -581,7 +581,11 @@ static void compileTerm(Token *&tok, AST_state& state)
|
|||
tok = tok->next();
|
||||
if (state.inArrayAssignment && tok->str() == "." && Token::Match(tok->previous(), ",|{")) // Jump over . in C style struct initialization
|
||||
tok = tok->next();
|
||||
|
||||
if (state.inArrayAssignment && Token::Match(tok->previous(), "[,{] [ %num% ]")) {
|
||||
state.op.push(tok);
|
||||
tok->astOperand1(tok->next());
|
||||
tok = tok->tokAt(3);
|
||||
}
|
||||
if (tok->isLiteral()) {
|
||||
state.op.push(tok);
|
||||
do {
|
||||
|
|
|
@ -8070,6 +8070,7 @@ private:
|
|||
ASSERT_EQUALS("tset{=", testAst("struct cgroup_taskset tset = {};"));
|
||||
ASSERT_EQUALS("s1a&,{2b&,{,{=", testAst("s = { {1, &a}, {2, &b} };"));
|
||||
TODO_ASSERT_EQUALS("xatoistr({(=", "x{(= atoistr(", testAst("x = (struct X){atoi(str)};"));
|
||||
ASSERT_EQUALS("s0[L.2[x={=", testAst("s = { [0].L[2] = x};"));
|
||||
|
||||
// struct initialization hang
|
||||
ASSERT_EQUALS("sbar1{,{(={= fcmd( forfieldfield++;;(",
|
||||
|
|
Loading…
Reference in New Issue