| 1 |
/* testing flexible array members in unions and alone in structures: |
| 2 |
__bos/__bdos */ |
| 3 |
/* { dg-do run } */ |
| 4 |
/* { dg-options "-O2" } */ |
| 5 |
|
| 6 |
union with_fam_1 { |
| 7 |
char a; |
| 8 |
int b[]; |
| 9 |
} with_fam_1_v = {.b = {1, 2, 3, 4, 5}}; |
| 10 |
|
| 11 |
union with_fam_2 { |
| 12 |
int a; |
| 13 |
char b[]; |
| 14 |
} with_fam_2_v = {.a = 0x1f2f3f4f}; |
| 15 |
|
| 16 |
union with_fam_3 { |
| 17 |
char a[]; |
| 18 |
int b[]; |
| 19 |
} with_fam_3_v = {.b = {0x1f2f3f4f, 0x5f6f7f7f}}; |
| 20 |
|
| 21 |
struct only_fam { |
| 22 |
int b[]; |
| 23 |
} only_fam_v = {{7, 11}}; |
| 24 |
|
| 25 |
struct only_fam_2 { |
| 26 |
unsigned int : 2; |
| 27 |
unsigned int : 3; |
| 28 |
int b[]; |
| 29 |
} only_fam_2_v = {{7, 11}}; |
| 30 |
|
| 31 |
int main () |
| 32 |
{ |
| 33 |
if (__builtin_object_size(with_fam_1_v.b, 1) != 20) |
| 34 |
__builtin_abort (); |
| 35 |
if (__builtin_object_size(with_fam_2_v.b, 1) != 4) |
| 36 |
__builtin_abort (); |
| 37 |
if (__builtin_object_size(with_fam_3_v.b, 1) != 8) |
| 38 |
__builtin_abort (); |
| 39 |
if (__builtin_object_size(only_fam_v.b, 1) != 8) |
| 40 |
__builtin_abort (); |
| 41 |
if (__builtin_object_size(only_fam_2_v.b, 1) != 8) |
| 42 |
__builtin_abort (); |
| 43 |
|
| 44 |
return 0; |
| 45 |
} |