Skip to content

Commit 9414292

Browse files
committed
SC_Obligations: assert that scope entities are set only once per CU
Instrumenters are not supposed to set scope entities once, and then override them later for the same CU: ensure this with an assertion.
1 parent fd2d2a7 commit 9414292

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tools/gnatcov/sc_obligations.adb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4362,9 +4362,15 @@ package body SC_Obligations is
43624362
------------------------
43634363

43644364
procedure Set_Scope_Entities
4365-
(CU : CU_Id; Scope_Entities : Scope_Entities_Trees.Tree) is
4365+
(CU : CU_Id; Scope_Entities : Scope_Entities_Trees.Tree)
4366+
is
4367+
SE : Scope_Entities_Trees.Tree renames
4368+
CU_Vector.Reference (CU).Scope_Entities;
43664369
begin
4367-
CU_Vector.Reference (CU).Scope_Entities := Scope_Entities;
4370+
-- Scopes are supposed to be set only once per compilation unit
4371+
4372+
pragma Assert (SE.Is_Empty);
4373+
SE := Scope_Entities;
43684374
end Set_Scope_Entities;
43694375

43704376
-------------------------------

0 commit comments

Comments
 (0)