-- formal parameter in a return context and we return the library
-- level to null them out there.
+ -- Note that we have to deal specifically with _Wrapped_Statements
+ -- functions of functions returning an access result, generated by
+ -- the expansion of contracts and postconditions, because they get
+ -- the same anonymous access result type as their parent function.
+
if Is_Explicitly_Aliased (E)
- and then Scope (E) = Current_Subprogram
+ and then (Scope (E) = Current_Subprogram
+ or else (Has_Expanded_Contract (Scope (E))
+ and then
+ Wrapped_Statements (Scope (E)) =
+ Current_Subprogram))
and then (In_Return_Value (Expr) or else In_Return_Context)
then
return Make_Level_Literal (Scope_Depth (Standard_Standard));
-- Wrapped_Statements
-- Defined in functions, procedures, entries, and entry families. Refers
--- to the entity of the _Wrapped_Statements procedure, which gets
+-- to the entity of the _Wrapped_Statements subprogram, which gets
-- generated as part of the expansion of contracts and postconditions
-- and contains its enclosing subprogram's original source declarations
-- and statements.
-- Start of processing for In_Return_Value
begin
- -- Move through parent nodes to determine if Expr contributes to the
+ -- Move through parent nodes to determine if Exp contributes to the
-- return value of the current subprogram.
Parent_Loop : while Present (P) loop