Expand_Iterator_Loop_Over_Array turns a loop over an array:

   for Element of Array loop

into a loop with an explicit iteration variable, but it doesn't propagate the 
SLOC of Element onto the new iteration variable.  This results in inaccurate
information when precise coverage is requested, as the SLOC of the enclosing
loop statement is propagated instead.

The change fixes this issue by using the SLOC of iteration scheme for the
entire rewrite of the construct, except for the new loop statements which
still inherit the SLOC of the original loop statement.

No functional changes.

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

2017-12-05  Eric Botcazou  <ebotca...@adacore.com>

        * exp_ch5.adb (Expand_Iterator_Loop_Over_Array): Use the SLOC of the
        iteration scheme throughout, except for the new loop statement(s).

Index: exp_ch5.adb
===================================================================
--- exp_ch5.adb (revision 255410)
+++ exp_ch5.adb (working copy)
@@ -3673,7 +3673,7 @@
       Array_Typ  : constant Entity_Id  := Base_Type (Etype (Array_Node));
       Array_Dim  : constant Pos        := Number_Dimensions (Array_Typ);
       Id         : constant Entity_Id  := Defining_Identifier (I_Spec);
-      Loc        : constant Source_Ptr := Sloc (N);
+      Loc        : constant Source_Ptr := Sloc (Isc);
       Stats      : constant List_Id    := Statements (N);
       Core_Loop  : Node_Id;
       Dim1       : Int;
@@ -3734,7 +3734,7 @@
       end if;
 
       Core_Loop :=
-        Make_Loop_Statement (Loc,
+        Make_Loop_Statement (Sloc (N),
           Iteration_Scheme =>
             Make_Iteration_Scheme (Loc,
               Loop_Parameter_Specification =>
@@ -3771,7 +3771,7 @@
             --    end loop;
 
             Core_Loop :=
-              Make_Loop_Statement (Loc,
+              Make_Loop_Statement (Sloc (N),
                 Iteration_Scheme =>
                   Make_Iteration_Scheme (Loc,
                     Loop_Parameter_Specification =>

Reply via email to