diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/contracts.adb | 12 | ||||
-rw-r--r-- | gcc/ada/sem_prag.adb | 6 |
2 files changed, 13 insertions, 5 deletions
diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb index 15b65ee..7625abf 100644 --- a/gcc/ada/contracts.adb +++ b/gcc/ada/contracts.adb @@ -334,7 +334,7 @@ package body Contracts is if Is_OK_Classification then Add_Classification; - elsif Ekind (Id) in Access_Subprogram_Kind + elsif Ekind (Id) = E_Subprogram_Type and then Prag_Nam in Name_Precondition | Name_Postcondition then @@ -665,7 +665,10 @@ package body Contracts is Freeze_Id : Entity_Id := Empty) is Items : constant Node_Id := Contract (Subp_Id); - Subp_Decl : constant Node_Id := Unit_Declaration_Node (Subp_Id); + Subp_Decl : constant Node_Id := + (if Ekind (Subp_Id) = E_Subprogram_Type + then Associated_Node_For_Itype (Subp_Id) + else Unit_Declaration_Node (Subp_Id)); Saved_SM : constant SPARK_Mode_Type := SPARK_Mode; Saved_SMP : constant Node_Id := SPARK_Mode_Pragma; @@ -1593,8 +1596,9 @@ package body Contracts is -- Analyze Pre/Post on access-to-subprogram type - if Is_Access_Subprogram_Type (Type_Id) then - Analyze_Entry_Or_Subprogram_Contract (Type_Id); + if Ekind (Type_Id) in Access_Subprogram_Kind then + Analyze_Entry_Or_Subprogram_Contract + (Directly_Designated_Type (Type_Id)); end if; end Analyze_Type_Contract; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 0d62b04..0de410a 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -5265,7 +5265,11 @@ package body Sem_Prag is -- Chain the pragma on the contract for further processing by -- Analyze_Pre_Post_Condition_In_Decl_Part. - Add_Contract_Item (N, Subp_Id); + if Ekind (Subp_Id) in Access_Subprogram_Kind then + Add_Contract_Item (N, Directly_Designated_Type (Subp_Id)); + else + Add_Contract_Item (N, Subp_Id); + end if; -- Fully analyze the pragma when it appears inside an entry or -- subprogram body because it cannot benefit from forward references. |