The Ada RM states that "For a formal access-to-subprogram subtype, the
designated profiles of the formal and the actual shall be subtype
conformant." (section 12.5.4). This requires checking if both types can
or can't be null.

Tested on x86_64-pc-linux-gnu, committed on trunk

2019-12-16  Ghjuvan Lacambre  <lacam...@adacore.com>

gcc/ada/

        * sem_ch12.adb (Validate_Access_Subprogram_Instance): Add
        Can_Never_Be_Null checks.
--- gcc/ada/sem_ch12.adb
+++ gcc/ada/sem_ch12.adb
@@ -12303,6 +12303,12 @@ package body Sem_Ch12 is
             Error_Msg_NE
               ("actual for formal & must have convention %", Actual, Gen_T);
          end if;
+
+         if Can_Never_Be_Null (A_Gen_T) /= Can_Never_Be_Null (Act_T) then
+            Error_Msg_NE
+               ("non null exclusion of actual and formal & do not match",
+               Actual, Gen_T);
+         end if;
       end Validate_Access_Subprogram_Instance;
 
       -----------------------------------

Reply via email to