--  Forms whose types come from their context or from each other (RM 8.6): a condition of a
--  type derived from Boolean, short circuits of it, range bounds of several possible types,
--  a unary operand, the root numeric operators preferred, a view conversion to a private
--  tagged type as an `in out` actual, and a positional aggregate of a variant record.
with Ada.Text_IO;
procedure Main is
   type Bit is new Boolean;
   X : constant Bit := True;
   Y : Bit := False;
   type Enum is ('A', 'B', Z);
   type E is (False, True);
   type Natural_Int is new Integer range 1 .. 1000;
   function "+" (L, R : Natural_Int) return Natural_Int is (L)
     with Pre => L < 1000;
   package P is
      type Root is tagged private;
      procedure Bump (R : in out Root);
      function Count (R : Root) return Integer;
   private
      type Root is tagged record
         N : Integer := 0;
      end record;
   end P;
   package body P is
      procedure Bump (R : in out Root) is
      begin
         if R.N < 100 then
            R.N := R.N + 1;
         end if;
      end Bump;
      function Count (R : Root) return Integer is (R.N);
   end P;
   type Child is new P.Root with record
      M : Integer := 0;
   end record;
   C : Child;
   type Rec (D : Boolean := True) is record
      A : Integer;
      case D is
         when Standard.True => Ch : Character;
         when Standard.False => V : Integer;
      end case;
   end record;
   R : constant Rec := (Standard.False, 3, 7);
   N : Integer := 0;
begin
   if X then
      Y := not Y;
   end if;
   if (X and then Y) = Bit'(True) and not False = X then
      N := 1;
   end if;
   for I in 'A' .. Enum'(Z) loop
      if N < 100 then
         N := N + 1;
      end if;
   end loop;
   for I in False .. E'(True) loop
      if N < 100 then
         N := N + 1;
      end if;
   end loop;
   pragma Assert (Natural_Int'Pos (3) + 1 = 4);
   P.Bump (P.Root (C));
   pragma Assert (P.Count (P.Root (C)) = 1);
   pragma Assert (R.V = 7);
   Ada.Text_IO.Put_Line (Integer'Image (N) & Integer'Image (R.V) & Integer'Image (P.Count (P.Root (C))));
end Main;
