Added support for C99 compound literals.

This commit is contained in:
Roberto Raggi
2009-01-13 14:58:29 +01:00
parent dd235e2b48
commit 248480b7c9
9 changed files with 103 additions and 3 deletions

View File

@@ -1621,8 +1621,7 @@ bool Parser::parseInitializerClause(ExpressionAST *&node)
ArrayInitializerAST *ast = new (_pool) ArrayInitializerAST;
ast->lbrace_token = consumeToken();
parseInitializerList(ast->expression_list);
if (LA() == T_RBRACE)
ast->rbrace_token = consumeToken();
match(T_RBRACE, &ast->rbrace_token);
node = ast;
return true;
}
@@ -2702,8 +2701,30 @@ bool Parser::parseCorePostfixExpression(ExpressionAST *&node)
return true;
}
}
blockErrors(blocked);
rewind(start);
// look for compound literals
if (LA() == T_LPAREN) {
unsigned lparen_token = consumeToken();
ExpressionAST *type_id = 0;
if (parseTypeId(type_id) && LA() == T_RPAREN) {
unsigned rparen_token = consumeToken();
if (LA() == T_LBRACE) {
blockErrors(blocked);
CompoundLiteralAST *ast = new (_pool) CompoundLiteralAST;
ast->lparen_token = lparen_token;
ast->type_id = type_id;
ast->rparen_token = rparen_token;
parseInitializerClause(ast->initializer);
node = ast;
return true;
}
}
rewind(start);
}
blockErrors(blocked);
return parsePrimaryExpression(node);
}
}