Loc : constant Source_Ptr := Sloc (N);
Func_Id : constant Entity_Id :=
Return_Applies_To (Return_Statement_Entity (N));
- Is_BIP_Func : constant Boolean :=
- Is_Build_In_Place_Function (Func_Id);
Ret_Obj_Id : constant Entity_Id :=
First_Entity (Return_Statement_Entity (N));
Ret_Obj_Decl : constant Node_Id := Parent (Ret_Obj_Id);
-- master. But Move_Activation_Chain updates their master to be that
-- of the caller, so they will not be terminated unless the return
-- statement completes unsuccessfully due to exception, abort, goto,
- -- or exit. As a formality, we test whether the function requires the
- -- result to be built in place, though that's necessarily true for
- -- the case of result types with task parts.
-
- if Is_BIP_Func and then Has_Task (Ret_Typ) then
+ -- or exit. Note that we test that the function is both BIP and has
+ -- implicit task formal parameters, because not all functions whose
+ -- result type contains tasks have them (see Needs_BIP_Task_Actuals).
+ if Is_Build_In_Place_Function (Func_Id)
+ and then Needs_BIP_Task_Actuals (Func_Id)
+ then
-- The return expression is an aggregate for a complex type which
-- contains tasks. This particular case is left unexpanded since
-- the regular expansion would insert all temporaries and
-- Do not move the activation chain if the return object does not
-- contain tasks.
- if Has_Task (Etype (Ret_Obj_Id)) then
+ if Might_Have_Tasks (Etype (Ret_Obj_Id)) then
Append_To (Stmts, Move_Activation_Chain (Func_Id));
end if;
end if;
-- BIP_Collection parameter (see type BIP_Formal_Kind).
function Needs_BIP_Task_Actuals (Func_Id : Entity_Id) return Boolean;
- -- Return True if the function returns an object of a type that has tasks.
+ -- Ada 2005 (AI-318-02): Return True if the function needs implicit
+ -- BIP_Task_Master and BIP_Activation_Chain parameters.
function Unqual_BIP_Iface_Function_Call (Expr : Node_Id) return Node_Id;
-- Return the inner BIP function call removing any qualification from Expr