AST: Fixed AST for struct initialisation

This commit is contained in:
Daniel Marjamäki 2015-07-21 11:40:42 +02:00
parent 149d11d9ad
commit 8a72bb8aa8
2 changed files with 5 additions and 1 deletions

View File

@ -540,7 +540,10 @@ static void compileTerm(Token *&tok, AST_state& state)
if (tok->link() != tok->next()) {
state.inArrayAssignment++;
compileUnaryOp(tok, state, compileExpression);
while (Token::Match(tok, "} [,}]") && state.inArrayAssignment > 0U) {
tok = tok->next();
state.inArrayAssignment--;
}
} else {
state.op.push(tok);
}

View File

@ -8598,6 +8598,7 @@ private:
ASSERT_EQUALS("name_bytes[bits~unusedBits>>unusedBits<<{=", testAst("const uint8_t name_bytes[] = { (~bits >> unusedBits) << unusedBits };"));
ASSERT_EQUALS("abuf0{={=", testAst("a = { .buf = { 0 } };"));
ASSERT_EQUALS("tset{=", testAst("struct cgroup_taskset tset = {};"));
ASSERT_EQUALS("s1a&,{2b&,{,{=", testAst("s = { {1, &a}, {2, &b} };"));
// template paratheses: <>
ASSERT_EQUALS("stdfabs::m_similarity(numeric_limitsepsilon::(<=return", testAst("return std::fabs(m_similarity) <= numeric_limits<double>::epsilon();")); // #6195