1-- { dg-do compile } 2-- { dg-options "-O -fdump-tree-optimized" } 3 4procedure Loop_Optimization20 is 5 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; 11 12 type T is access Obj_T; 13 14 function Is_Null (S1 : Obj_T) return Boolean; 15 pragma No_Inline (Is_Null); 16 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; 26 27 A : T := new Obj_T'(Length => 10, Elements => (others => 0)); 28 29begin 30 if not Is_Null (A.all) then 31 raise Program_Error; 32 end if; 33end; 34 35-- { dg-final { scan-tree-dump-not "Index_Check" "optimized" } } 36