Commit 393e63ce by Robert Dewar Committed by Arnaud Charlet

einfo.adb (Spec_PPC): Now defined for generic subprograms

2008-07-31  Robert Dewar  <dewar@adacore.com>

	* einfo.adb (Spec_PPC): Now defined for generic subprograms
	
	* einfo.ads (Spec_PPC): Now defined for generic subprograms
	
	* sem_prag.adb (Check_Precondition_Postcondition): Handle generic
	subprogram case

From-SVN: r138370
parent 024238a2
...@@ -2579,7 +2579,7 @@ package body Einfo is ...@@ -2579,7 +2579,7 @@ package body Einfo is
function Spec_PPC_List (Id : E) return N is function Spec_PPC_List (Id : E) return N is
begin begin
pragma Assert (Is_Subprogram (Id)); pragma Assert (Is_Subprogram (Id) or else Is_Generic_Subprogram (Id));
return Node24 (Id); return Node24 (Id);
end Spec_PPC_List; end Spec_PPC_List;
...@@ -5044,7 +5044,7 @@ package body Einfo is ...@@ -5044,7 +5044,7 @@ package body Einfo is
procedure Set_Spec_PPC_List (Id : E; V : N) is procedure Set_Spec_PPC_List (Id : E; V : N) is
begin begin
pragma Assert (Is_Subprogram (Id)); pragma Assert (Is_Subprogram (Id) or else Is_Generic_Subprogram (Id));
Set_Node24 (Id, V); Set_Node24 (Id, V);
end Set_Spec_PPC_List; end Set_Spec_PPC_List;
......
...@@ -3527,10 +3527,11 @@ package Einfo is ...@@ -3527,10 +3527,11 @@ package Einfo is
-- the corresponding parameter entities in the spec. -- the corresponding parameter entities in the spec.
-- Spec_PPC_List (Node24) -- Spec_PPC_List (Node24)
-- Present in subprogram entities. Points to a list of Precondition -- Present in subprogram and generic subprogram entities. Points to a
-- and Postcondition N_Pragma nodes for preconditions and postconditions -- list of Precondition and Postcondition pragma nodes for preconditions
-- declared in the spec. The last pragma encountered is at the head of -- and postconditions declared in the spec. The last pragma encountered
-- this list, so it is in reverse order of textual appearance. -- is at the head of this list, so it is in reverse order of textual
-- appearance.
-- Storage_Size_Variable (Node15) [implementation base type only] -- Storage_Size_Variable (Node15) [implementation base type only]
-- Present in access types and task type entities. This flag is set -- Present in access types and task type entities. This flag is set
...@@ -5277,7 +5278,7 @@ package Einfo is ...@@ -5277,7 +5278,7 @@ package Einfo is
-- Generic_Renamings (Elist23) (for instance) -- Generic_Renamings (Elist23) (for instance)
-- Inner_Instances (Elist23) (for generic proc) -- Inner_Instances (Elist23) (for generic proc)
-- Protection_Object (Node23) (for concurrent kind) -- Protection_Object (Node23) (for concurrent kind)
-- Spec_PPC_List (Node24) (non-generic case only) -- Spec_PPC_List (Node24)
-- Interface_Alias (Node25) -- Interface_Alias (Node25)
-- Static_Initialization (Node26) (init_proc only) -- Static_Initialization (Node26) (init_proc only)
-- Overridden_Operation (Node26) -- Overridden_Operation (Node26)
......
...@@ -1354,9 +1354,10 @@ package body Sem_Prag is ...@@ -1354,9 +1354,10 @@ package body Sem_Prag is
PO : Node_Id; PO : Node_Id;
procedure Chain_PPC (PO : Node_Id); procedure Chain_PPC (PO : Node_Id);
-- PO is the N_Subprogram_Declaration node for the subprogram to -- If PO is a subprogram declaration node (or a generic subprogram
-- which the precondition/postcondition applies. This procedure -- declaration node), then the precondition/postcondition applies
-- completes the processing for the pragma. -- to this subprogram and the processing for the pragma is completed.
-- Otherwise the pragma is misplaced.
--------------- ---------------
-- Chain_PPC -- -- Chain_PPC --
...@@ -1366,6 +1367,14 @@ package body Sem_Prag is ...@@ -1366,6 +1367,14 @@ package body Sem_Prag is
S : Node_Id; S : Node_Id;
begin 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)); S := Defining_Unit_Name (Specification (PO));
-- Analyze the pragma unless it appears within a package spec, -- Analyze the pragma unless it appears within a package spec,
...@@ -1427,16 +1436,11 @@ package body Sem_Prag is ...@@ -1427,16 +1436,11 @@ package body Sem_Prag is
elsif not Comes_From_Source (PO) then elsif not Comes_From_Source (PO) then
null; 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); Chain_PPC (PO);
return; return;
-- If we encounter any other declaration moving back, misplaced
else
Pragma_Misplaced;
end if; end if;
end loop; end loop;
...@@ -1452,14 +1456,8 @@ package body Sem_Prag is ...@@ -1452,14 +1456,8 @@ package body Sem_Prag is
-- See if it is in the pragmas after a library level subprogram -- See if it is in the pragmas after a library level subprogram
elsif Nkind (Parent (N)) = N_Compilation_Unit_Aux then elsif Nkind (Parent (N)) = N_Compilation_Unit_Aux then
declare Chain_PPC (Unit (Parent (Parent (N))));
Decl : constant Node_Id := Unit (Parent (Parent (N))); return;
begin
if Nkind (Decl) = N_Subprogram_Declaration then
Chain_PPC (Decl);
return;
end if;
end;
end if; end if;
-- If we fall through, pragma was misplaced -- If we fall through, pragma was misplaced
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment