AI05-288 specifies that subtype conformance is required for actual types for generic formal access-to-subprogram types, rather than just mode conformance. This is a binding interpretation.
Compiling pack2.adb must yield: pack2.adb:4:37: not subtype conformant with declaration at pack1.ads:2 pack2.adb:4:37: type of "N" does not match generic type ACC is access procedure (N : Natural); package Pack1 is procedure Test1 (A : out ACC); end Pack1; --- package body Pack1 is procedure Test1 (A : out ACC) is begin null; end Test1; end Pack1; --- package Pack2 is procedure Cause_A_Problem; end Pack2; --- with Pack1; package body Pack2 is type Actual_Acc is access procedure (N : Integer); package New_Pack1 is new Pack1 (Actual_Acc); procedure Cause_A_Problem is X : Actual_Acc; begin New_Pack1.Test1 (X); X (-1); -- PROBLEM end Cause_A_Problem; end Pack2; --- Tested on x86_64-pc-linux-gnu, committed on trunk 2012-03-15 Ed Schonberg <schonb...@adacore.com> * sem_ch6.ads, sem_ch6.adb (Check_Subtype_Conformant): add Get_Inst formal, so that conformance within an instantiation follows renamings of formals. This is similar to what is already done in Check_Mode_conformant. * sem_ch12.adb (Vailidate_Access_Subprogram_Instance): check that formal and actual are subtype conformant. Previously only mode conformance was required.
Index: sem_ch12.adb =================================================================== --- sem_ch12.adb (revision 185390) +++ sem_ch12.adb (working copy) @@ -10433,7 +10433,11 @@ Abandon_Instantiation (Actual); end if; - Check_Mode_Conformant + -- In Ada 2012, actuals for access_to_subprograms must be subtype + -- conformant with the generic formal. Previous to AI05-288 only mode + -- conformance was required. + + Check_Subtype_Conformant (Designated_Type (Act_T), Designated_Type (A_Gen_T), Actual, Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 185390) +++ sem_ch6.adb (working copy) @@ -7251,14 +7251,16 @@ (New_Id : Entity_Id; Old_Id : Entity_Id; Err_Loc : Node_Id := Empty; - Skip_Controlling_Formals : Boolean := False) + Skip_Controlling_Formals : Boolean := False; + Get_Inst : Boolean := False) is Result : Boolean; pragma Warnings (Off, Result); begin Check_Conformance (New_Id, Old_Id, Subtype_Conformant, True, Result, Err_Loc, - Skip_Controlling_Formals => Skip_Controlling_Formals); + Skip_Controlling_Formals => Skip_Controlling_Formals, + Get_Inst => Get_Inst); end Check_Subtype_Conformant; --------------------------- Index: sem_ch6.ads =================================================================== --- sem_ch6.ads (revision 185390) +++ sem_ch6.ads (working copy) @@ -28,7 +28,7 @@ type Conformance_Type is (Type_Conformant, Mode_Conformant, Subtype_Conformant, Fully_Conformant); - pragma Ordered (Conformance_Type); + -- pragma Ordered (Conformance_Type); -- Conformance type used in conformance checks between specs and bodies, -- and for overriding. The literals match the RM definitions of the -- corresponding terms. This is an ordered type, since each conformance @@ -141,7 +141,8 @@ (New_Id : Entity_Id; Old_Id : Entity_Id; Err_Loc : Node_Id := Empty; - Skip_Controlling_Formals : Boolean := False); + Skip_Controlling_Formals : Boolean := False; + Get_Inst : Boolean := False); -- Check that two callable entities (subprograms, entries, literals) -- are subtype conformant, post error message if not (RM 6.3.1(16)), -- the flag being placed on the Err_Loc node if it is specified, and