--  An `out` parameter's discriminants are its actual's, initialised from the start (RM
--  6.4.1(12)): read before anything is assigned, through renamings and in a component; a
--  record of discriminants alone needs no value (ACATS C62006A, C85007A, C85007E; D262).
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   type R1 (D1 : Integer) is record
      null;
   end record;
   type R2 (D2 : Positive) is record
      C : R1 (2);
   end record;
   type R (D : Positive) is record
      C : Integer;
   end record;
   R_Of_Five : R2 (5);
   V : R (5);
   procedure Read (Rec : out R2) is
      Again : R2 renames Rec;
   begin
      Put_Line (Integer'Image (Rec.D2) & Integer'Image (Rec.C.D1) & Integer'Image (Again.D2));
   end Read;
   procedure Set (X : out R) is
   begin
      if X.D = 5 then
         X := (5, 1);
      else
         X := (X.D, 0);
      end if;
   end Set;
begin
   Read (R_Of_Five);
   Set (V);
   pragma Assert (V.C = 1);
   Put_Line (Integer'Image (V.C));
end Main;
