This change fixes incorrect source location indications in SCOs for decisions
corresponding to guard expressions in SELECT statements, which can cause
a crash in coverage analysis tools.

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

2012-07-23  Thomas Quinot  <qui...@adacore.com>

        * par_sco.adb (Process_Decisions.Output_Header): For the guard
        on an alternative in a SELECT statement, use the First_Sloc
        of the guard expression (not its topmost sloc) as the decision
        location, because this is what is referenced by dominance markers.

Index: par_sco.adb
===================================================================
--- par_sco.adb (revision 189768)
+++ par_sco.adb (working copy)
@@ -25,6 +25,7 @@
 
 with Atree;    use Atree;
 with Debug;    use Debug;
+with Errout;   use Errout;
 with Lib;      use Lib;
 with Lib.Util; use Lib.Util;
 with Namet;    use Namet;
@@ -495,13 +496,15 @@
                --  levels (through the pragma argument association) to get to
                --  the pragma node itself. For the guard on a select
                --  alternative, we do not have access to the token location
-               --  for the WHEN, so we use the sloc of the condition itself.
+               --  for the WHEN, so we use the first sloc of the condition
+               --  itself (note: we use First_Sloc, not Sloc, because this is
+               --  what is referenced by dominance markers).
 
                if Nkind_In (Parent (N), N_Accept_Alternative,
                                         N_Delay_Alternative,
                                         N_Terminate_Alternative)
                then
-                  Loc := Sloc (N);
+                  Loc := First_Sloc (N);
                else
                   Loc := Sloc (Parent (Parent (N)));
                end if;

Reply via email to