An untagged incomeplete type is legal in the profile of a null procedure.
This patch remotes a spurious error on such, because the legality check
for the use of an incomplete type was also applied to the subprogram body
generated during expansion of a null procedure declaration.
The following must compile quietly:
gcc -c c.ads
---
package A is
type T is abstract tagged limited private;
procedure Prim (This : in T) is abstract;
type Access_T is access T;
private
type T is tagged null record;
end A;
---
package B is
type T is new Integer;
end B;
---
limited with A;
limited with B;
package C is
procedure P1 (That : in A.T'Class) is null;
procedure P2 (That : access A.T'Class) is null;
procedure P3 (That : in A.Access_T) is null;
procedure P4 (That : in B.T) is null;
end C;
Tested on x86_64-pc-linux-gnu, committed on trunk
2015-05-12 Ed Schonberg <[email protected]>
* sem_ch6.adb (Process_Formals): An untagged incomplete type
is legal in the profile of a null procedure.
Index: sem_ch6.adb
===================================================================
--- sem_ch6.adb (revision 223064)
+++ sem_ch6.adb (working copy)
@@ -9882,6 +9882,7 @@
(T : List_Id;
Related_Nod : Node_Id)
is
+ Context : constant Node_Id := Parent (Parent (T));
Param_Spec : Node_Id;
Formal : Entity_Id;
Formal_Type : Entity_Id;
@@ -10027,6 +10028,8 @@
-- Incomplete formal untagged types are not allowed in
-- subprogram bodies (but are legal in their declarations).
+ -- This excludes bodies created for null procedures, which
+ -- are basic declarations.
if Is_Generic_Type (Formal_Type)
and then not Is_Tagged_Type (Formal_Type)
@@ -10042,13 +10045,14 @@
then
null;
- elsif Nkind_In (Parent (Parent (T)), N_Accept_Statement,
- N_Accept_Alternative,
- N_Entry_Body,
- N_Subprogram_Body)
+ elsif Nkind_In (Context, N_Accept_Statement,
+ N_Accept_Alternative,
+ N_Entry_Body)
+ or else (Nkind (Context) = N_Subprogram_Body
+ and then Comes_From_Source (Context))
then
Error_Msg_NE
- ("invalid use of untagged incomplete type&",
+ ("invalid use of untagged incomplete type &",
Ptype, Formal_Type);
end if;