- -- freeze outside this body, not inside it, and we skip
- -- past the subprogram body that we are inside.
-
- if In_Expanded_Body (Parent_P) then
- declare
- Subp_Body : constant Node_Id := Parent (Parent_P);
- Spec_Id : Entity_Id;
-
- begin
- -- Freeze the entity only when it is declared inside
- -- the body of the expander generated procedure. This
- -- case is recognized by the subprogram scope of the
- -- entity or its type, which is either the spec of an
- -- enclosing body, or (in the case of init_procs for
- -- which there is no separate spec) the current scope.
-
- if Nkind (Subp_Body) = N_Subprogram_Body then
- declare
- S : Entity_Id;
-
- begin
- Spec_Id := Corresponding_Spec (Subp_Body);
-
- if Present (Typ) then
- S := Scope (Typ);
- elsif Present (Nam) then
- S := Scope (Nam);
- else
- S := Standard_Standard;
- end if;
-
- while S /= Standard_Standard
- and then not Is_Subprogram (S)
- loop
- S := Scope (S);
- end loop;
-
- if S = Spec_Id then
- exit;
-
- elsif Present (Typ)
- and then Scope (Typ) = Current_Scope
- and then
- Defining_Entity (Subp_Body) = Current_Scope
- then
- exit;
- end if;
- end;
- end if;
-
- -- If the entity is not frozen by an expression
- -- function that is not a completion, continue
- -- climbing the tree.
+ -- freeze outside this body, not inside it, unless the
+ -- entity is declared inside this expander generated body.