@@ -246,13 +246,20 @@ package SC_Obligations is
246246 -- Is_Active to know whether a given scope is active in the given
247247 -- traversal.
248248
249- function Scope_Traversal (CU : CU_Id) return Scope_Traversal_Type;
249+ function Scope_Traversal (CU : CU_Id) return Scope_Traversal_Type
250+ with Post => Last_SCO (Scope_Traversal'Result) = No_SCO_Id;
250251 -- Return a scope traversal for the given compilation unit
251252
252- procedure Traverse_SCO (ST : in out Scope_Traversal_Type; SCO : SCO_Id);
253+ procedure Traverse_SCO (ST : in out Scope_Traversal_Type; SCO : SCO_Id)
254+ with Pre => Last_SCO (ST) <= SCO,
255+ Post => Last_SCO (ST) = SCO;
253256 -- Traverse the given SCO and update the Scope_Traversal accordingly. Note
254257 -- that the scope traversal must be done on increasing SCOs identifiers.
255258
259+ function Last_SCO (ST : Scope_Traversal_Type) return SCO_Id;
260+ -- Return the last SCO that was passed to Traverse_SCO, or No_SCO_Id if
261+ -- Traverse_SCO has not been called yet on ST.
262+
256263 function Is_Active
257264 (ST : Scope_Traversal_Type;
258265 Subps_Of_Interest : Scope_Id_Set) return Boolean;
@@ -1376,6 +1383,11 @@ private
13761383
13771384 It : Iterator_Acc;
13781385 -- Iterator to traverse the scope tree
1386+
1387+ Last_SCO : SCO_Id;
1388+ -- Keep track of the last SCO requested with Traverse_SCO. We use this
1389+ -- to check that SCOs are requested in the right order (lower Ids to
1390+ -- higher ones).
13791391 end record ;
13801392
13811393 procedure Set_Active_Scope_Ent
@@ -1389,6 +1401,7 @@ private
13891401 Active_Scopes => Scope_Id_Sets.Empty_Set,
13901402 Active_Scope_Ent => Scope_Entities_Trees.No_Element,
13911403 Next_Scope_Ent => Scope_Entities_Trees.No_Element,
1392- It => null );
1404+ It => null ,
1405+ Last_SCO => No_SCO_Id);
13931406
13941407end SC_Obligations ;
0 commit comments