public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Eric Botcazou <ebotcazou@adacore.com>
Subject: [Ada] Propagate SLOC in iteration over array
Date: Tue, 05 Dec 2017 11:58:00 -0000	[thread overview]
Message-ID: <20171205115830.GA121461@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 833 bytes --]

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  <ebotcazou@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).


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1173 bytes --]

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	other threads:[~2017-12-05 11:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171205115830.GA121461@adacore.com \
    --to=derodat@adacore.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).