1 /* { dg-do run } */ 2 3 #include <stdio.h> 4 5 #include "init6.h" 6 #include "dump.h" 7 8 #ifdef __cplusplus 9 extern "C" 10 #endif 11 void abort (void); 12 Get_Elem1(struct R1 R)13int Get_Elem1 (struct R1 R) 14 { 15 struct R1 Tmp = R; 16 return Tmp.N.A[0]; 17 } 18 Set_Elem1(struct R1 * R,int I)19void Set_Elem1 (struct R1 *R, int I) 20 { 21 struct R1 Tmp = *R; 22 Tmp.N.A[0] = I; 23 *R = Tmp; 24 } 25 Get_Elem2(struct R2 R)26int Get_Elem2 (struct R2 R) 27 { 28 struct R2 Tmp = R; 29 return Tmp.N.A[0]; 30 } 31 Set_Elem2(struct R2 * R,int I)32void Set_Elem2 (struct R2 *R, int I) 33 { 34 struct R2 Tmp = *R; 35 Tmp.N.A[0] = I; 36 *R = Tmp; 37 } 38 main(void)39int 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 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } */ 48 49 put ("A2 :"); 50 dump (&A2, sizeof (struct R2)); 51 new_line (); 52 /* { dg-output "A2 : 12 34 56 78 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\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 } 67