analyzer: Fix PR analyzer/101980
[official-gcc.git] / gcc / testsuite / gnat.dg / exit1.adb
blob2598e7e6c9855177feab2d921982105eed298985
1 -- { dg-do run }
2 -- { dg-output "1 2 3 4 5 6 7 \| 1- 1 2 3 2- 1 2 3 3- 1 2 3 4- 1 2 3 5- 1 2 3" }
4 with Ada.Text_IO; use Ada.Text_IO;
6 procedure Exit1 is
7 type Int_Range is record
8 First, Last : Integer;
9 end record
10 with Iterable => (First => First,
11 Next => Next,
12 Previous => Previous,
13 Last => Last,
14 Has_Element => Has_Element,
15 Element => Element);
17 function First (IR : Int_Range) return Integer is (IR.First);
18 function Last (IR : Int_Range) return Integer is (IR.Last);
19 function Next (IR : Int_Range; N : Integer) return Integer is (N + 1);
20 function Previous (IR : Int_Range; N : Integer) return Integer is (N - 1);
21 function Has_Element (IR : Int_Range; N : Integer) return Boolean is
22 (N in IR.First ..IR.Last);
23 function Element (IR : Int_Range; N : Integer) return Integer is (N);
25 IR : Int_Range := (1, 10);
27 begin
28 A_Loop: for I of IR loop
29 Put (I'Img);
30 exit A_Loop when I = 7;
31 end loop A_Loop;
32 Put (" | ");
34 B_Loop: for I of IR loop
35 Put (I'Img & '-');
36 C_Loop : for J of IR loop
37 Put (J'Img);
38 exit when J = 3;
39 end loop C_Loop;
41 exit B_Loop when I = 5;
42 end loop B_Loop;
43 New_Line;
45 end Exit1;