| 1 |
/* { dg-do run } */ |
| 2 |
|
| 3 |
#include <stdio.h> |
| 4 |
|
| 5 |
#include "init7.h" |
| 6 |
#include "dump.h" |
| 7 |
|
| 8 |
#ifdef __cplusplus |
| 9 |
extern "C" |
| 10 |
#endif |
| 11 |
void abort (void); |
| 12 |
|
| 13 |
int Get_Elem1 (struct R1 R) |
| 14 |
{ |
| 15 |
struct R1 Tmp = R; |
| 16 |
return Tmp.N.C1; |
| 17 |
} |
| 18 |
|
| 19 |
void Set_Elem1 (struct R1 *R, int I) |
| 20 |
{ |
| 21 |
struct R1 Tmp = *R; |
| 22 |
Tmp.N.C1 = I; |
| 23 |
*R = Tmp; |
| 24 |
} |
| 25 |
|
| 26 |
int Get_Elem2 (struct R2 R) |
| 27 |
{ |
| 28 |
struct R2 Tmp = R; |
| 29 |
return Tmp.N.C1; |
| 30 |
} |
| 31 |
|
| 32 |
void Set_Elem2 (struct R2 *R, int I) |
| 33 |
{ |
| 34 |
struct R2 Tmp = *R; |
| 35 |
Tmp.N.C1 = I; |
| 36 |
*R = Tmp; |
| 37 |
} |
| 38 |
|
| 39 |
int main (void) |
| 40 |
{ |
| 41 |
struct R1 A1 = My_R1; |
| 42 |
struct R2 A2 = My_R2; |
| 43 |
|
| 44 |
put ("A1 :"); |
| 45 |
dump (&A1, sizeof (struct R1)); |
| 46 |
new_line (); |
| 47 |
/* { dg-output "A1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } */ |
| 48 |
|
| 49 |
put ("A2 :"); |
| 50 |
dump (&A2, sizeof (struct R2)); |
| 51 |
new_line (); |
| 52 |
/* { dg-output "A2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } */ |
| 53 |
|
| 54 |
if (Get_Elem1 (A1) != 0xAB0012) abort (); |
| 55 |
|
| 56 |
Set_Elem1 (&A1, 0xCD0034); |
| 57 |
if (Get_Elem1 (A1) != 0xCD0034) abort (); |
| 58 |
|
| 59 |
if (Get_Elem2 (A2) != 0xAB0012) abort (); |
| 60 |
|
| 61 |
Set_Elem2 (&A2, 0xCD0034); |
| 62 |
if (Get_Elem2 (A2) != 0xCD0034) abort (); |
| 63 |
|
| 64 |
new_line (); |
| 65 |
return 0; |
| 66 |
} |