procedure Build_Predicate_Function (Typ : Entity_Id; N : Node_Id) is
Loc : constant Source_Ptr := Sloc (Typ);
+ Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
+ Saved_IGR : constant Node_Id := Ignored_Ghost_Region;
+ -- Save the Ghost-related attributes to restore on exit
+
Expr : Node_Id;
-- This is the expression for the result of the function. It is
-- is build by connecting the component predicates with AND THEN.
SId : Entity_Id;
-- Its entity
+ Restore_Scope : Boolean;
+ -- True if the current scope must be restored on exit
+
Ancestor_Predicate_Function_Called : Boolean := False;
-- Does this predicate function include a call to the
-- predication function of an ancestor subtype?
Replace_Type_References (N, Typ);
end Replace_Current_Instance_References;
- -- Local variables
-
- Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
- Saved_IGR : constant Node_Id := Ignored_Ghost_Region;
- -- Save the Ghost-related attributes to restore on exit
-
-- Start of processing for Build_Predicate_Function
begin
return;
end if;
+ -- Ensure that the declarations are added to the scope of the type
+
+ if Scope (Typ) /= Current_Scope then
+ Push_Scope (Scope (Typ));
+ Restore_Scope := True;
+ else
+ Restore_Scope := False;
+ end if;
+
-- The related type may be subject to pragma Ghost. Set the mode now to
-- ensure that the predicate functions are properly marked as Ghost.
end if;
Restore_Ghost_Region (Saved_GM, Saved_IGR);
+
+ if Restore_Scope then
+ Pop_Scope;
+ end if;
end Build_Predicate_Function;
------------------------------------------
return S;
end Current_Scope_No_Loops;
- --------------------------------------
- -- Current_Scope_No_Loops_No_Blocks --
- --------------------------------------
-
- function Current_Scope_No_Loops_No_Blocks return Entity_Id is
- S : Entity_Id;
-
- begin
- -- Examine the scope stack starting from the current scope and skip any
- -- internally generated loops and blocks.
-
- S := Current_Scope;
- while Present (S) and then S /= Standard_Standard loop
- if Ekind (S) in E_Loop | E_Block
- and then not Comes_From_Source (S)
- then
- S := Scope (S);
- else
- exit;
- end if;
- end loop;
-
- return S;
- end Current_Scope_No_Loops_No_Blocks;
-
------------------------
-- Current_Subprogram --
------------------------
-----------------------
procedure Set_Public_Status (Id : Entity_Id) is
- S : constant Entity_Id := Current_Scope_No_Loops_No_Blocks;
+ S : constant Entity_Id := Current_Scope;
function Within_HSS_Or_If (E : Entity_Id) return Boolean;
-- Determines if E is defined within handled statement sequence or
function Current_Scope_No_Loops return Entity_Id;
-- Return the current scope ignoring internally generated loops
- function Current_Scope_No_Loops_No_Blocks return Entity_Id;
- -- Return the current scope ignoring internally generated loops and blocks
-
procedure Add_Block_Identifier
(N : Node_Id;
Id : out Entity_Id;