gcc/testsuite/gcc.dg/gnu23-tag-composite-4.c
raw| 1 | /* { dg-do run } */ |
| 2 | /* { dg-options "-O2 -std=gnu23" } */ |
| 3 | |
| 4 | // struct with variable size |
| 5 | |
| 6 | |
| 7 | |
| 8 | int |
| 9 | foo () |
| 10 | { |
| 11 | int n = 10; |
| 12 | struct s { char buf[n]; } s; |
| 13 | { |
| 14 | int m = 10; |
| 15 | struct s { char buf[m]; } t; |
| 16 | typeof(*(1 ? &s : &t)) u; |
| 17 | return sizeof(u.buf); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | int main() |
| 22 | { |
| 23 | if (10 != foo()) |
| 24 | __builtin_abort(); |
| 25 | |
| 26 | return 0; |
| 27 | } |
| 28 |