PR testsuite/86649
[official-gcc.git] / gcc / testsuite / gnat.dg / loop_optimization20.adb
blob729799e605a2001dc369b083ede392697221e9ef
1 -- { dg-do compile }
2 -- { dg-options "-O -fdump-tree-optimized" }
4 procedure Loop_Optimization20 is
6 type Array_T is array (Positive range <>) of Integer;
7 type Obj_T (Length : Natural) is
8 record
9 Elements : Array_T (1 .. Length);
10 end record;
12 type T is access Obj_T;
14 function Is_Null (S1 : Obj_T) return Boolean;
15 pragma No_Inline (Is_Null);
17 function Is_Null (S1 : Obj_T) return Boolean is
18 begin
19 for I in 1 .. S1.Length loop
20 if S1.Elements (I) /= 0 then
21 return False;
22 end if;
23 end loop;
24 return True;
25 end;
27 A : T := new Obj_T'(Length => 10, Elements => (others => 0));
29 begin
30 if not Is_Null (A.all) then
31 raise Program_Error;
32 end if;
33 end;
35 -- { dg-final { scan-tree-dump-not "Index_Check" "optimized" } }