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
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)));
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);