function Spec_PPC_List (Id : E) return N is
begin
- pragma Assert (Is_Subprogram (Id));
+ pragma Assert (Is_Subprogram (Id) or else Is_Generic_Subprogram (Id));
return Node24 (Id);
end Spec_PPC_List;
procedure Set_Spec_PPC_List (Id : E; V : N) is
begin
- pragma Assert (Is_Subprogram (Id));
+ pragma Assert (Is_Subprogram (Id) or else Is_Generic_Subprogram (Id));
Set_Node24 (Id, V);
end Set_Spec_PPC_List;
-- the corresponding parameter entities in the spec.
-- Spec_PPC_List (Node24)
--- Present in subprogram entities. Points to a list of Precondition
--- and Postcondition N_Pragma nodes for preconditions and postconditions
--- declared in the spec. The last pragma encountered is at the head of
--- this list, so it is in reverse order of textual appearance.
+-- Present in subprogram and generic subprogram entities. Points to a
+-- list of Precondition and Postcondition pragma nodes for preconditions
+-- and postconditions declared in the spec. The last pragma encountered
+-- is at the head of this list, so it is in reverse order of textual
+-- appearance.
-- Storage_Size_Variable (Node15) [implementation base type only]
-- Present in access types and task type entities. This flag is set
-- Generic_Renamings (Elist23) (for instance)
-- Inner_Instances (Elist23) (for generic proc)
-- Protection_Object (Node23) (for concurrent kind)
- -- Spec_PPC_List (Node24) (non-generic case only)
+ -- Spec_PPC_List (Node24)
-- Interface_Alias (Node25)
-- Static_Initialization (Node26) (init_proc only)
-- Overridden_Operation (Node26)
PO : Node_Id;
procedure Chain_PPC (PO : Node_Id);
- -- PO is the N_Subprogram_Declaration node for the subprogram to
- -- which the precondition/postcondition applies. This procedure
- -- completes the processing for the pragma.
+ -- If PO is a subprogram declaration node (or a generic subprogram
+ -- declaration node), then the precondition/postcondition applies
+ -- to this subprogram and the processing for the pragma is completed.
+ -- Otherwise the pragma is misplaced.
---------------
-- Chain_PPC --
S : Node_Id;
begin
+ if not Nkind_In (PO, N_Subprogram_Declaration,
+ N_Generic_Subprogram_Declaration)
+ then
+ Pragma_Misplaced;
+ end if;
+
+ -- Here if we have subprogram or generic subprogram declaration
+
S := Defining_Unit_Name (Specification (PO));
-- Analyze the pragma unless it appears within a package spec,
elsif not Comes_From_Source (PO) then
null;
- -- Here if we hit a subprogram declaration
+ -- Only remaining possibility is subprogram declaration
- elsif Nkind (PO) = N_Subprogram_Declaration then
+ else
Chain_PPC (PO);
return;
-
- -- If we encounter any other declaration moving back, misplaced
-
- else
- Pragma_Misplaced;
end if;
end loop;
-- See if it is in the pragmas after a library level subprogram
elsif Nkind (Parent (N)) = N_Compilation_Unit_Aux then
- declare
- Decl : constant Node_Id := Unit (Parent (Parent (N)));
- begin
- if Nkind (Decl) = N_Subprogram_Declaration then
- Chain_PPC (Decl);
- return;
- end if;
- end;
+ Chain_PPC (Unit (Parent (Parent (N))));
+ return;
end if;
-- If we fall through, pragma was misplaced