return;
else
- -- The resolution of a controlled [extension] aggregate associated
- -- with a return statement creates a temporary which needs to be
- -- finalized on function exit. Wrap the return statement inside a
- -- block so that the finalization machinery can detect this case.
- -- This early expansion is done only when the return statement is
- -- not part of a handled sequence of statements.
-
- if Nkind (Expr) in N_Aggregate | N_Extension_Aggregate
- and then Needs_Finalization (R_Type)
- and then Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements
- then
- Rewrite (N,
- Make_Block_Statement (Loc,
- Handled_Statement_Sequence =>
- Make_Handled_Sequence_Of_Statements (Loc,
- Statements => New_List (Relocate_Node (N)))));
-
- Analyze (N);
- return;
- end if;
-
Analyze (Expr);
-- Ada 2005 (AI-251): If the type of the returned object is