| 1 |
/* Test support of scalar_storage_order pragma */ |
| 2 |
|
| 3 |
/* { dg-do run } */ |
| 4 |
/* { dg-options "-fsso-struct=little-endian" } */ |
| 5 |
/* { dg-require-effective-target int32plus } */ |
| 6 |
|
| 7 |
struct S1 |
| 8 |
{ |
| 9 |
int i; |
| 10 |
}; |
| 11 |
|
| 12 |
#pragma scalar_storage_order big-endian |
| 13 |
|
| 14 |
struct S2 |
| 15 |
{ |
| 16 |
int i; |
| 17 |
}; |
| 18 |
|
| 19 |
#pragma scalar_storage_order default |
| 20 |
|
| 21 |
struct S3 |
| 22 |
{ |
| 23 |
int i; |
| 24 |
}; |
| 25 |
|
| 26 |
struct S1 my_s1 = { 0x12345678 }; |
| 27 |
struct S2 my_s2 = { 0x12345678 }; |
| 28 |
struct S3 my_s3 = { 0x12345678 }; |
| 29 |
|
| 30 |
unsigned char big_endian_pattern[4] = { 0x12, 0x34, 0x56, 0x78 }; |
| 31 |
unsigned char little_endian_pattern[4] = { 0x78, 0x56, 0x34, 0x12 }; |
| 32 |
|
| 33 |
int main (void) |
| 34 |
{ |
| 35 |
if (__builtin_memcmp (&my_s1, &little_endian_pattern, 4) != 0) |
| 36 |
__builtin_abort (); |
| 37 |
|
| 38 |
if (__builtin_memcmp (&my_s2, &big_endian_pattern, 4) != 0) |
| 39 |
__builtin_abort (); |
| 40 |
|
| 41 |
if (__builtin_memcmp (&my_s3, &little_endian_pattern, 4) != 0) |
| 42 |
__builtin_abort (); |
| 43 |
|
| 44 |
return 0; |
| 45 |
} |