Pragma_Argument_Associations => Args,
Class_Present => Class_Present);
- Subp_Decl : Node_Id := Subp_Id;
+ Subp_Decl : constant Node_Id := Enclosing_Declaration (Subp_Id);
+ pragma Assert (Is_Declaration (Subp_Decl));
begin
- -- Enclosing_Declaration may return, for example,
- -- a N_Procedure_Specification node. Cope with this.
- loop
- Subp_Decl := Enclosing_Declaration (Subp_Decl);
- exit when Is_Declaration (Subp_Decl);
- Subp_Decl := Parent (Subp_Decl);
- pragma Assert (Present (Subp_Decl));
- end loop;
-
Insert_After_And_Analyze (Subp_Decl, Prag);
end Insert_Stable_Property_Check;
--------------------------
function In_Available_Context (Ent : Entity_Id) return Boolean is
- Decl : Node_Id := Enclosing_Declaration (Ent);
+ Decl : constant Node_Id := Enclosing_Declaration (Ent);
begin
- -- Enclosing_Declaration does not always return a declaration;
- -- cope with this irregularity.
- if Decl in N_Subprogram_Specification_Id
- and then Nkind (Parent (Decl)) in
- N_Subprogram_Body | N_Subprogram_Declaration
- then
- Decl := Parent (Decl);
- end if;
-
if Has_Declarations (Parent (Decl)) then
return In_Subtree (Attr_Ref, Root => Parent (Decl));
elsif Is_List_Member (Decl) then
Decl := Enclosing_Declaration (E);
- -- Enclosing_Declaration does not always return a
- -- declaration; cope with this irregularity.
- if Decl in N_Subprogram_Specification_Id
- and then Nkind (Parent (Decl)) in
- N_Subprogram_Body | N_Subprogram_Declaration
- | N_Subprogram_Renaming_Declaration
- then
- Decl := Parent (Decl);
- end if;
-
-- Look for the suprogram renaming declaration built
-- for a generic actual subprogram. Unclear why
-- Original_Node call is needed, but sometimes it is.
Decl := Parent (Decl);
end loop;
+ -- cope with oddness in definition of N_Declaration
+ if Nkind (Decl) in N_Subprogram_Specification then
+ Decl := Parent (Decl);
+ end if;
+
return Decl;
end Enclosing_Declaration;