--  Aggregates whose bounds or choices are known only at run time (D192): a range beside
--  `others` (B7005-01), `others` and an iteration for an unconstrained target (-10, -11),
--  delta aggregates of an unconstrained array and with a run-time range (-12, -19), a
--  rectangular array's named rows beside `others` (-21), and a filter known only at run time
--  (-16); proved and run.
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   type Vector is array (Positive range <>) of Integer;
   type Fixed is array (1 .. 10) of Integer;
   type Grid is array (Positive range <>, Positive range <>) of Integer;

   function Ident (X : Integer) return Integer is (X);

   procedure Reset (X : out Vector)
     with Pre => X'First = 1 and X'Length >= 2,
          Post => X (1) = 1 and X (2) = 2 and (for all J in 3 .. X'Last => X (J) = 0)
   is
   begin
      X := (for K in 1 .. 2 => K, others => 0);
   end Reset;

   procedure Clear (X : out Vector) with Post => (for all J in X'Range => X (J) = 7) is
   begin
      X := (others => 7);
   end Clear;

   function Bump (V : Vector) return Vector is (V with delta V'First => 0)
     with Pre => V'Length > 0, Post => Bump'Result'First = V'First and Bump'Result (V'First) = 0;

   N : constant Integer := Ident (6);
   Total : Integer := 0;
begin
   if N in 3 .. 8 then
      declare
         A : constant Vector (1 .. N) := (1 .. 2 => 5, others => 0);
         B : Vector (1 .. N);
         C : Vector (4 .. N + 3);
         D : constant Vector := Bump ((7, 8, 9));
         F : constant Fixed := (1 .. 10 => 1);
         G : constant Fixed := (F with delta 2 .. N => 0);
         H : constant Grid (1 .. N, 1 .. 3) := (2 => (others => 1), others => (others => 0));
         K : constant Fixed := [for J in 1 .. 20 when J mod N = 0 => J, others => -1];
      begin
         pragma Assert (A (1) = 5 and A (2) = 5 and A (3) = 0);
         Reset (B);
         Clear (C);
         pragma Assert (B (2) = 2 and C (5) = 7);
         pragma Assert (D (1) = 0);
         pragma Assert (G (1) = 1 and G (2) = 0 and G (N) = 0);
         Total := A (1) + A (N) + B (1) + B (2) + B (N) + C (N + 3) + D (1) + D (2) + G (1) + G (2) + G (N) + G (10) + H (2, 3) + H (1, 1) + K (1) + K (2) + K (4);
         Put_Line (Integer'Image (Total) & Integer'Image (D'First) & Integer'Image (D'Last) & Integer'Image (K (3)));
      end;
   end if;
end Main;
