ubuntu-buildroot/output/build/host-gcc-initial-11.4.0/gcc/testsuite/gnat.dg/opt81.adb

21 lines
539 B
Ada
Raw Permalink Normal View History

2024-04-01 15:19:46 +00:00
-- { 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;