summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/opt81.adb
blob: 057d846e5cd93d4f8217fcbd48298ea31c073f5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- { dg-do compile }
-- { dg-options "-O -gnatws" }

with Unchecked_Conversion;

package body Opt81 is

  procedure Copy (From, To : Rec) is
    Len : constant Natural := From.A.all'Length;
    subtype Fixed_String is String (1 .. Len);
    type Fixed_String_Access is access Fixed_String;
    function To_Fixed is new
      Unchecked_Conversion (Source => String_Access,
                            Target => Fixed_String_Access);
    S : Fixed_String_Access := To_Fixed (To.A);
  begin
    S (1 .. Len) := From.A.all;
  end;

end Opt81;