| 1 |
/* { dg-do run } */ |
| 2 |
|
| 3 |
#include <stdio.h> |
| 4 |
|
| 5 |
#include "init5.h" |
| 6 |
#include "dump.h" |
| 7 |
|
| 8 |
#pragma GCC diagnostic ignored "-Wscalar-storage-order" |
| 9 |
|
| 10 |
int main (void) |
| 11 |
{ |
| 12 |
struct R1 A1 = My_R1; |
| 13 |
struct R2 A2 = My_R2; |
| 14 |
|
| 15 |
struct __attribute__((scalar_storage_order("little-endian"))) Nested1 |
| 16 |
{ |
| 17 |
int A[3]; |
| 18 |
}; |
| 19 |
|
| 20 |
struct __attribute__((scalar_storage_order("big-endian"))) Nested2 |
| 21 |
{ |
| 22 |
int A[3]; |
| 23 |
}; |
| 24 |
|
| 25 |
struct Nested1 N1; |
| 26 |
struct Nested2 N2; |
| 27 |
|
| 28 |
int C1; |
| 29 |
int C2; |
| 30 |
int C3; |
| 31 |
|
| 32 |
put ("A1 :"); |
| 33 |
dump (&A1, sizeof (struct R1)); |
| 34 |
new_line (); |
| 35 |
/* { dg-output "A1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } */ |
| 36 |
|
| 37 |
put ("A2 :"); |
| 38 |
dump (&A2, sizeof (struct R2)); |
| 39 |
new_line (); |
| 40 |
/* { dg-output "A2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } */ |
| 41 |
|
| 42 |
__builtin_memcpy (N1.A, A1.A, sizeof (int) * 3); |
| 43 |
C1 = N1.A[0]; |
| 44 |
C2 = N1.A[1]; |
| 45 |
C3 = N1.A[2]; |
| 46 |
|
| 47 |
printf ("C1 : %d\n", C1); |
| 48 |
/* { dg-output "C1 : 11206674.*\n" } */ |
| 49 |
|
| 50 |
printf ("C2 : %d\n", C2); |
| 51 |
/* { dg-output "C2 : 13434932.*\n" } */ |
| 52 |
|
| 53 |
printf ("C3 : %d\n", C3); |
| 54 |
/* { dg-output "C3 : 15663190.*\n" } */ |
| 55 |
|
| 56 |
N1.A[0] = C1; |
| 57 |
N1.A[1] = C2; |
| 58 |
N1.A[2] = C3; |
| 59 |
__builtin_memcpy (A1.A, N1.A, sizeof (int) * 3); |
| 60 |
|
| 61 |
__builtin_memcpy (N2.A, A2.A, sizeof (int) * 3); |
| 62 |
C1 = N2.A[0]; |
| 63 |
C2 = N2.A[1]; |
| 64 |
C3 = N2.A[2]; |
| 65 |
|
| 66 |
printf ("C1 : %d\n", C1); |
| 67 |
/* { dg-output "C1 : 11206674.*\n" } */ |
| 68 |
|
| 69 |
printf ("C2 : %d\n", C2); |
| 70 |
/* { dg-output "C2 : 13434932.*\n" } */ |
| 71 |
|
| 72 |
printf ("C3 : %d\n", C3); |
| 73 |
/* { dg-output "C3 : 15663190.*\n" } */ |
| 74 |
|
| 75 |
N2.A[0] = C1; |
| 76 |
N2.A[1] = C2; |
| 77 |
N2.A[2] = C3; |
| 78 |
__builtin_memcpy (A2.A, N2.A, sizeof (int) * 3); |
| 79 |
|
| 80 |
put ("A1 :"); |
| 81 |
dump (&A1, sizeof (struct R1)); |
| 82 |
new_line (); |
| 83 |
/* { dg-output "A1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } */ |
| 84 |
|
| 85 |
put ("A2 :"); |
| 86 |
dump (&A2, sizeof (struct R2)); |
| 87 |
new_line (); |
| 88 |
/* { dg-output "A2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } */ |
| 89 |
|
| 90 |
new_line (); |
| 91 |
return 0; |
| 92 |
} |