[Ada] Fix to SCOs for SELECT alternatives with guard

Message ID 20120723081250.GA5030@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet July 23, 2012, 8:12 a.m.
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  <quinot@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,
-                  Loc := Sloc (N);
+                  Loc := First_Sloc (N);
                   Loc := Sloc (Parent (Parent (N)));
                end if;