Skip to content

Commit 2e36658

Browse files
committed
fix: add open bracket detection in array test
1 parent ff217d6 commit 2e36658

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/parser.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,8 +1864,9 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
18641864

18651865
/* Check what follows the closing ) */
18661866
if (lex_accept(T_close_bracket)) {
1867+
18671868
if (lex_peek(T_open_curly, NULL)) {
1868-
/* (type){...} - compound literal */
1869+
/* (type){...} - compound literal */
18691870
is_compound_literal = true;
18701871
cast_or_literal_type = type;
18711872
cast_ptr_level = ptr_level;
@@ -1891,7 +1892,7 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
18911892
}
18921893
}
18931894

1894-
/* add struct/union support (loretta) */
1895+
/* add struct/union support */
18951896
else if (lex_peek(T_struct, NULL) || lex_peek(T_union, NULL)) {
18961897
/* Check for (struct/union T){...} or (struct/union T)expr */
18971898
int saved_pos = SOURCE->size;
@@ -2071,6 +2072,9 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
20712072

20722073
} else if (cast_or_literal_type->base_type == TYPE_int ||
20732074
cast_or_literal_type->base_type == TYPE_char) {
2075+
/* Consume the opening { token */
2076+
lex_expect(T_open_curly);
2077+
20742078
/* Handle empty compound literals */
20752079
if (lex_peek(T_close_curly, NULL)) {
20762080
/* Empty compound literal: (int){} */
@@ -2339,8 +2343,8 @@ bool is_logical(opcode_t op)
23392343
return op == OP_log_and || op == OP_log_or;
23402344
}
23412345

2342-
/* Helper function to emit struct brace initializer(loretta) */
2343-
static void emit_struct_brace_initializer(block_t *parent,
2346+
/* Helper function to emit struct brace initializer */
2347+
void emit_struct_brace_initializer(block_t *parent,
23442348
basic_block_t **bb,
23452349
var_t *dest,
23462350
type_t *struct_type)

0 commit comments

Comments
 (0)