1-- { dg-do run } 2 3with Init3; use Init3; 4with Text_IO; use Text_IO; 5with Dump; 6 7procedure R3 is 8 9 function Get_Elem (R : R1) return Integer is 10 Tmp : R1 := R; 11 begin 12 return Tmp.I; 13 end; 14 15 procedure Set_Elem (R : access R1; I : Integer) is 16 Tmp : R1 := R.all; 17 begin 18 Tmp.I := I; 19 R.all := Tmp; 20 end; 21 22 function Get_Elem (R : R2) return Integer is 23 Tmp : R2 := R; 24 begin 25 return Tmp.I; 26 end; 27 28 procedure Set_Elem (R : access R2; I : Integer) is 29 Tmp : R2 := R.all; 30 begin 31 Tmp.I := I; 32 R.all := Tmp; 33 end; 34 35 A1 : aliased R1 := My_R1; 36 A2 : aliased R2 := My_R2; 37 38begin 39 40 Put ("A1 :"); 41 Dump (A1'Address, R1'Max_Size_In_Storage_Elements); 42 New_Line; 43 -- { dg-output "A1 : e2 59 d1 48 b4 aa d9 bb.*\n" } 44 45 Put ("A2 :"); 46 Dump (A2'Address, R1'Max_Size_In_Storage_Elements); 47 New_Line; 48 -- { dg-output "A2 : 84 8d 15 9e 15 5b 35 df.*\n" } 49 50 if Get_Elem (A1) /= 16#12345678# then 51 raise Program_Error; 52 end if; 53 54 Set_Elem (A1'Access, 16#CD0034#); 55 if Get_Elem (A1) /= 16#CD0034# then 56 raise Program_Error; 57 end if; 58 59 if Get_Elem (A2) /= 16#12345678# then 60 raise Program_Error; 61 end if; 62 63 Set_Elem (A2'Access, 16#CD0034#); 64 if Get_Elem (A2) /= 16#CD0034# then 65 raise Program_Error; 66 end if; 67 68end; 69