Skip to content

Commit 3daa913

Browse files
committed
Avoid crashing on wrong dominance marker sloc
GNATcoverage crashes on a constraint error when a SCO associated to a dominance marker is not found in the SCO decision map (because of wrong computed source location or whatever). It will now emit a warning in those cases, and discard dominance information when that happens. Change-Id: I457ca0e3676fb9cd089c396bdd67393cc6a363df TN: U219-010
1 parent b241688 commit 3daa913

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

tools/gnatcov/sc_obligations.adb

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3039,11 +3039,23 @@ package body SC_Obligations is
30393039
else
30403040
-- Case of >T / >F: dominant SCO is a decision
30413041

3042-
Dom_Sloc_SCO :=
3043-
Sloc_To_SCO_Map
3044-
(SCOD.Dominant_Sloc.Source_File, Decision)
3045-
.Element ((SCOD.Dominant_Sloc.L, No_Local_Location));
3046-
pragma Assert (Kind (Dom_Sloc_SCO) = Decision);
3042+
if Sloc_To_SCO_Map
3043+
(SCOD.Dominant_Sloc.Source_File, Decision)
3044+
.Contains ((SCOD.Dominant_Sloc.L, No_Local_Location))
3045+
then
3046+
Dom_Sloc_SCO :=
3047+
Sloc_To_SCO_Map
3048+
(SCOD.Dominant_Sloc.Source_File, Decision)
3049+
.Element ((SCOD.Dominant_Sloc.L, No_Local_Location));
3050+
pragma Assert (Kind (Dom_Sloc_SCO) = Decision);
3051+
else
3052+
Report
3053+
(First_Sloc (SCOD.Sloc_Range),
3054+
"dominant decision of statement " & Image (SCO)
3055+
& " has no associated SCO"
3056+
& ", discarding dominance information");
3057+
Dom_Sloc_SCO := No_SCO_Id;
3058+
end if;
30473059
end if;
30483060

30493061
SCOD.Dominant := Dom_Sloc_SCO;

0 commit comments

Comments
 (0)