This small change brings the indirect case on par with the direct case when it
comes to eliminating an index check for dynamic arrays.  No index check will
be generated for the following procedure in default mode:

   type Darray is array (1 .. Q.N) of Long_Float;

   procedure Add (X, Y : access Darray; R : access Darray) is
   begin
      for I in Darray'Range loop
         R(I) := X(I) + Y(I);
      end loop;
   end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-06  Eric Botcazou  <ebotca...@adacore.com>

        * checks.adb (Apply_Scalar_Range_Check): Deal with access
        type prefix.

Index: checks.adb
===================================================================
--- checks.adb  (revision 178565)
+++ checks.adb  (working copy)
@@ -1877,6 +1877,9 @@
       if Is_Subscr_Ref then
          Arr := Prefix (Parnt);
          Arr_Typ := Get_Actual_Subtype_If_Available (Arr);
+         if Is_Access_Type (Arr_Typ) then
+            Arr_Typ := Directly_Designated_Type (Arr_Typ);
+         end if;
       end if;
 
       if not Do_Range_Check (Expr) then

Reply via email to