mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
Allow $defined take declarations: $defined(int x = y)
Taking the address of a label would cause a crash. #2430
This commit is contained in:
@@ -95,20 +95,6 @@ bool parse_generic_expr_list(ParseContext *c, Expr ***exprs_ref)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool parse_expr_list(ParseContext *c, Expr ***exprs_ref, TokenType end_token)
|
||||
{
|
||||
while (!try_consume(c, end_token))
|
||||
{
|
||||
ASSIGN_EXPR_OR_RET(Expr *expr, parse_expr(c), false);
|
||||
vec_add(*exprs_ref, expr);
|
||||
if (!try_consume(c, TOKEN_COMMA))
|
||||
{
|
||||
CONSUME_OR_RET(end_token, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* rethrow_expr ::= call_expr '!'
|
||||
@@ -1170,7 +1156,18 @@ static Expr *parse_ct_defined(ParseContext *c, Expr *left, SourceSpan lhs_start
|
||||
Expr *defined = expr_new(EXPR_CT_DEFINED, c->span);
|
||||
advance(c);
|
||||
CONSUME_OR_RET(TOKEN_LPAREN, poisoned_expr);
|
||||
if (!parse_expr_list(c, &defined->expression_list, TOKEN_RPAREN)) return poisoned_expr;
|
||||
while (!try_consume(c, TOKEN_RPAREN))
|
||||
{
|
||||
|
||||
ASSIGN_EXPR_OR_RET(Expr *expr, parse_decl_or_expr(c), poisoned_expr);
|
||||
vec_add(defined->expression_list, expr);
|
||||
if (!try_consume(c, TOKEN_COMMA))
|
||||
{
|
||||
CONSUME_OR_RET(TOKEN_RPAREN, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
RANGE_EXTEND_PREV(defined);
|
||||
return defined;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user