===================================================================
@@ -2664,6 +2664,14 @@
Error_Msg_N
("abstract formal subprogram must have a controlling type",
N);
+
+ elsif Ada_Version >= Ada_2012
+ and then Is_Incomplete_Type (Ctrl_Type)
+ then
+ Error_Msg_NE
+ ("controlling type of abstract formal subprogram cannot " &
+ "be incomplete type", N, Ctrl_Type);
+
else
Check_Controlling_Formals (Ctrl_Type, Nam);
end if;
@@ -9411,6 +9419,59 @@
end;
end if;
+ -- In Ada 2012, enforce the (RM 13.14(10.2/3)) freezing rule concerning
+ -- formal incomplete types: a callable entity freezes its profile,
+ -- unless it has an incomplete untagged formal.
+
+ if Ada_Version >= Ada_2012 then
+ declare
+ F : Entity_Id;
+ Has_Untagged_Inc : Boolean;
+
+ begin
+ F := First_Formal (Analyzed_S);
+ Has_Untagged_Inc := False;
+ while Present (F) loop
+ if Ekind (Etype (F)) = E_Incomplete_Type
+ and then not Is_Tagged_Type (Etype (F))
+ then
+ Has_Untagged_Inc := True;
+ exit;
+ end if;
+
+ F := Next_Formal (F);
+ end loop;
+
+ if Ekind (Analyzed_S) = E_Function
+ and then Ekind (Etype (Analyzed_S)) = E_Incomplete_Type
+ and then not Is_Tagged_Type (Etype (F))
+ then
+ Has_Untagged_Inc := True;
+ end if;
+
+ if Is_Entity_Name (Actual)
+ and then not Has_Untagged_Inc
+ then
+ F := First_Formal (Entity (Actual));
+ while Present (F) loop
+ Freeze_Before (Instantiation_Node, Etype (F));
+
+ if Is_Incomplete_Or_Private_Type (Etype (F))
+ and then No (Full_View (Etype (F)))
+ and then not Is_Generic_Type (Etype (F))
+ then
+ Error_Msg_NE
+ ("type& must be frozen before this point",
+ Instantiation_Node, Etype (F));
+ Abandon_Instantiation (Instantiation_Node);
+ end if;
+
+ F := Next_Formal (F);
+ end loop;
+ end if;
+ end;
+ end if;
+
return Decl_Node;
end Instantiate_Formal_Subprogram;
===================================================================
@@ -4340,12 +4340,16 @@
when E_Incomplete_Type =>
if Ada_Version >= Ada_2005 then
- Set_Ekind (Id, E_Incomplete_Subtype);
- -- Ada 2005 (AI-412): Decorate an incomplete subtype
- -- of an incomplete type visible through a limited
- -- with clause.
+ -- A subtype of an incomplete type can be explicitly tagged
+ Set_Ekind (Id, E_Incomplete_Subtype);
+ Set_Is_Tagged_Type (Id, Is_Tagged_Type (T));
+ Set_Private_Dependents (Id, New_Elmt_List);
+
+ -- Ada 2005 (AI-412): Decorate an incomplete subtype of an
+ -- incomplete type visible through a limited with clause.
+
if From_With_Type (T)
and then Present (Non_Limited_View (T))
then