Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / sso-6.c
blobe955fa93686f599adf625159e04fb87fc8cc89a2
1 /* Test support of scalar_storage_order pragma */
3 /* { dg-do run } */
4 /* { dg-require-effective-target int32plus } */
6 #pragma scalar_storage_order /* { dg-warning "missing .big-endian.little-endian.default." } */
8 #pragma scalar_storage_order big-endian
10 struct S1
12 int i;
15 struct __attribute__((scalar_storage_order("little-endian"))) S2
17 int i;
20 #pragma scalar_storage_order little-endian
22 struct S3
24 int i;
27 struct __attribute__((scalar_storage_order("big-endian"))) S4
29 int i;
32 #pragma scalar_storage_order default
34 struct S5
36 int i;
39 #pragma scalar_storage_order other /* { dg-warning "expected .big-endian.little-endian.default." } */
41 struct S1 my_s1 = { 0x12345678 };
42 struct S2 my_s2 = { 0x12345678 };
43 struct S3 my_s3 = { 0x12345678 };
44 struct S4 my_s4 = { 0x12345678 };
45 struct S5 my_s5 = { 0x12345678 };
47 unsigned char big_endian_pattern[4] = { 0x12, 0x34, 0x56, 0x78 };
48 unsigned char little_endian_pattern[4] = { 0x78, 0x56, 0x34, 0x12 };
50 int main (void)
52 if (__builtin_memcmp (&my_s1, &big_endian_pattern, 4) != 0)
53 __builtin_abort ();
55 if (__builtin_memcmp (&my_s2, &little_endian_pattern, 4) != 0)
56 __builtin_abort ();
58 if (__builtin_memcmp (&my_s3, &little_endian_pattern, 4) != 0)
59 __builtin_abort ();
61 if (__builtin_memcmp (&my_s4, &big_endian_pattern, 4) != 0)
62 __builtin_abort ();
64 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
65 if (__builtin_memcmp (&my_s5, &little_endian_pattern, 4) != 0)
66 __builtin_abort ();
67 #else
68 if (__builtin_memcmp (&my_s5, &big_endian_pattern, 4) != 0)
69 __builtin_abort ();
70 #endif
72 return 0;