AST: Fix wrong handling of struct initialization, caused hang

This commit is contained in:
Daniel Marjamäki 2017-04-09 22:06:13 +02:00
parent 45d2d66df3
commit d92c529aa6
2 changed files with 6 additions and 0 deletions

View File

@ -628,6 +628,7 @@ static void compileTerm(Token *&tok, AST_state& state)
}
} else {
state.op.push(tok);
tok = tok->tokAt(2);
}
}
}

View File

@ -8071,6 +8071,11 @@ private:
ASSERT_EQUALS("s1a&,{2b&,{,{=", testAst("s = { {1, &a}, {2, &b} };"));
TODO_ASSERT_EQUALS("xatoistr({(=", "x{(= atoistr(", testAst("x = (struct X){atoi(str)};"));
// struct initialization hang
ASSERT_EQUALS("sbar1{,{(={= fcmd( forfieldfield++;;(",
testAst("struct S s = {.bar = (struct foo) { 1, { } } };\n"
"void f(struct cmd *) { for (; field; field++) {} }"));
// template parentheses: <>
ASSERT_EQUALS("stdfabs::m_similarity(numeric_limitsepsilon::(<=return", testAst("return std::fabs(m_similarity) <= numeric_limits<double>::epsilon();")); // #6195