Skip to content

Commit 3336ed7

Browse files
committed
fix: add open bracket detection in array test
1 parent af16c8b commit 3336ed7

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
@@ -1967,8 +1967,9 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
19671967

19681968
/* Check what follows the closing ) */
19691969
if (lex_accept(T_close_bracket)) {
1970+
19701971
if (lex_peek(T_open_curly, NULL)) {
1971-
/* (type){...} - compound literal */
1972+
/* (type){...} - compound literal */
19721973
is_compound_literal = true;
19731974
cast_or_literal_type = type;
19741975
cast_ptr_level = ptr_level;
@@ -1994,7 +1995,7 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
19941995
}
19951996
}
19961997

1997-
/* add struct/union support (loretta) */
1998+
/* add struct/union support */
19981999
else if (lex_peek(T_struct, NULL) || lex_peek(T_union, NULL)) {
19992000
/* Check for (struct/union T){...} or (struct/union T)expr */
20002001
int saved_pos = SOURCE->size;
@@ -2175,6 +2176,9 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
21752176
} else if (cast_or_literal_type->base_type == TYPE_int ||
21762177
cast_or_literal_type->base_type == TYPE_short ||
21772178
cast_or_literal_type->base_type == TYPE_char) {
2179+
/* Consume the opening { token */
2180+
lex_expect(T_open_curly);
2181+
21782182
/* Handle empty compound literals */
21792183
if (lex_peek(T_close_curly, NULL)) {
21802184
/* Empty compound literal: (int){} */
@@ -2443,8 +2447,8 @@ bool is_logical(opcode_t op)
24432447
return op == OP_log_and || op == OP_log_or;
24442448
}
24452449

2446-
/* Helper function to emit struct brace initializer(loretta) */
2447-
static void emit_struct_brace_initializer(block_t *parent,
2450+
/* Helper function to emit struct brace initializer */
2451+
void emit_struct_brace_initializer(block_t *parent,
24482452
basic_block_t **bb,
24492453
var_t *dest,
24502454
type_t *struct_type)

0 commit comments

Comments
 (0)