Files
Bogdan Barbu 5a1124e4f5 runtime(c): compound literal braces are highlighted as errors
Problem: Braces in C compound literals and initializers inside parentheses
         and brackets are highlighted as errors.

Solution: Recognize those initializer blocks while preserving syntax recovery
          for malformed parentheses.

fixes:  #18709
closes: #20842

Signed-off-by: Bogdan Barbu <l4b.bogdan.barbu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2026-08-04 21:11:56 +00:00

19 lines
637 B
C

// Compound literals and initializers inside expressions
void test(void)
{
int a[(struct foo){ 42 }.bar];
struct foo b = ((struct foo){ });
_Static_assert(sizeof (int []){ 1, 2, 3 } == 3 * sizeof (int), "");
for (struct foo i = { };;) break;
int c[(struct foo) <% 42 %>.bar];
struct foo d = ((struct foo) <% %>);
f((int [2][2]){{ 1, 2 }, { 3, 4 }});
syscall(SYS_clock_settime, CLOCK_REALTIME,
tv ? &((struct timespec){ .tv_sec = tv->tv_sec,
.tv_nsec = tv->tv_usec * 1000 }) : 0);
f((struct timespec)
<% .tv_sec = 0 %>);
int e[){ 42 }.bar];
f(a { 1 }); f(a, { 1 });
}