diff --git a/gcc/ada/par-ch10.adb b/gcc/ada/par-ch10.adb index 7317b75a1a5d1e53f811d0454b385efb9f339ece..576614f09019d5bbc83aa8fa4287eab2e8e0a180 100644 --- a/gcc/ada/par-ch10.adb +++ b/gcc/ada/par-ch10.adb @@ -532,6 +532,15 @@ package body Ch10 is Unit_Node := Specification (Unit_Node); end if; + -- Disallow null procedures as library units and subunits + + if Nkind (Unit_Node) = N_Procedure_Specification + and then Null_Present (Unit_Node) + then + Error_Msg_N + ("null procedure cannot be used as compilation unit", Unit_Node); + end if; + if Nkind (Unit_Node) in N_Task_Body | N_Protected_Body | N_Task_Type_Declaration diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index d0aaa6c10503ccfb96b9b84fbde4f21662650641..fee6583d5359279f3e3d6536075b54c55d10e748 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -2820,20 +2820,14 @@ package body Sem_Ch10 is Install_Elaboration_Model (Par_Unit); - -- The syntax rules require a proper body for a subprogram subunit + -- The syntax rules require a proper body for a subprogram subunit. + -- Note that we already checked for "is null" in the parser. if Nkind (Proper_Body (Sinfo.Nodes.Unit (N))) = N_Subprogram_Declaration then - if Null_Present (Specification (Proper_Body (Sinfo.Nodes.Unit (N)))) - then - Error_Msg_N - ("null procedure not allowed as subunit", - Proper_Body (Unit (N))); - else - Error_Msg_N - ("subprogram declaration not allowed as subunit", - Defining_Unit_Name (Specification (Proper_Body (Unit (N))))); - end if; + Error_Msg_N + ("subprogram declaration not allowed as subunit", + Defining_Unit_Name (Specification (Proper_Body (Unit (N))))); end if; Analyze (Proper_Body (Unit (N))); diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 2e619d89444aa736e1603dd4903dc4b22b721361..1e91bf810ef122343a59c75208d7e694a414316b 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -5156,14 +5156,6 @@ package body Sem_Ch6 is if Nkind (Parent (N)) = N_Compilation_Unit then Set_Body_Required (Parent (N), True); - - if Ada_Version >= Ada_2005 - and then Nkind (Specification (N)) = N_Procedure_Specification - and then Null_Present (Specification (N)) - then - Error_Msg_N - ("null procedure cannot be declared at library level", N); - end if; end if; Generate_Reference_To_Formals (Designator);