return False;
end Has_Unconstrained_Access_Discriminants;
- --------------------------------
- -- Is_Anonymous_Access_Actual --
- --------------------------------
+ ---------------------------------------------
+ -- Needs_Accessibility_Level_Temp_Or_Check --
+ ---------------------------------------------
- function Is_Anonymous_Access_Actual (N : Node_Id) return Boolean is
+ function Needs_Accessibility_Level_Temp_Or_Check
+ (Conditional_Expr : Node_Id) return Boolean
+ is
Par : Node_Id;
begin
- if Ekind (Etype (N)) /= E_Anonymous_Access_Type then
+ if Ekind (Etype (Conditional_Expr)) /= E_Anonymous_Access_Type then
return False;
end if;
- Par := Parent (N);
+ Par := Parent (Conditional_Expr);
while Present (Par)
and then Nkind (Par) in N_Case_Expression
| N_If_Expression
loop
Par := Parent (Par);
end loop;
- return Nkind (Par) in N_Subprogram_Call;
- end Is_Anonymous_Access_Actual;
+
+ return Nkind (Par) in N_Subprogram_Call | N_Assignment_Statement;
+ end Needs_Accessibility_Level_Temp_Or_Check;
--------------------------------------
-- Needs_Result_Accessibility_Level --
-- When in the context of the function Accessibility_Level,
-- Accessibility_Level_Kind signals what type of accessibility level to
-- obtain. For example, when Level is Dynamic_Level, a defining identifier
- -- associated with a SAOOAAT may be returned or an N_Integer_Literal node.
+ -- associated with a saooaaat may be returned or an N_Integer_Literal node.
-- When the level is Object_Decl_Level, an N_Integer_Literal node is
-- returned containing the level of the declaration of the object if
- -- relevant (be it a SAOOAAT or otherwise). Finally, Zero_On_Dynamic_Level
+ -- relevant (be it a saooaaat or otherwise). Finally, Zero_On_Dynamic_Level
-- returns library level for all cases where the accessibility level is
-- dynamic (used to bypass static accessibility checks in dynamic cases).
-- Returns True if the given subtype is unconstrained and has one or more
-- access discriminants.
- function Is_Anonymous_Access_Actual (N : Node_Id) return Boolean;
- -- Determine if N is used as an actual for a call whose corresponding
- -- formal is of an anonymous access type.
+ function Needs_Accessibility_Level_Temp_Or_Check
+ (Conditional_Expr : Node_Id) return Boolean;
+ -- Determine whether a conditional expression occurs in a context that
+ -- requires either an associated accessibility-level-valued temp (which
+ -- is assigned to in each arm of the conditional expression) or an
+ -- accessibility level check (which is pushed down into each arm of the
+ -- conditional expression).
function Needs_Result_Accessibility_Level
(Func_Id : Entity_Id) return Boolean;
Par : constant Node_Id := Parent (N);
Typ : constant Entity_Id := Etype (N);
- Force_Expand : constant Boolean := Is_Anonymous_Access_Actual (N);
+ Force_Expand : constant Boolean
+ := Needs_Accessibility_Level_Temp_Or_Check (N);
-- Determine if we are dealing with a special case of a conditional
-- expression used as an actual for an anonymous access type which
-- forces us to transform the if expression into an expression with
-- actions in order to create a temporary to capture the level of the
- -- expression in each branch.
+ -- expression in each branch. Also True if the conditional
+ -- expression is the RHS of an assignment to a saooaaat (so the
+ -- accessibility level temp associated with the saooaaat also needs
+ -- to be updated as part of the assignment).
function Is_Copy_Type (Typ : Entity_Id) return Boolean;
-- Return True if we can copy objects of this type when expanding an if