sem_ch3.adb (Analyze_Subtype_Declaration): if an incomplete type is tagged, so is a subtype of it.
2012-06-12 Ed Schonberg <schonberg@adacore.com> * sem_ch3.adb (Analyze_Subtype_Declaration): if an incomplete type is tagged, so is a subtype of it. * sem_ch12.adb (Validate_Actual_Subprogram): implement AI05-0296, concerning freeze rules in the presence of formal incomplete types: a formal abstract subprogram cannot have an incomplete controlling type, and the profile of the actual subprogram does not freeze if it includes an incomplete untagged type. From-SVN: r188442
This commit is contained in:
parent
02f5883431
commit
967e927f1b
|
@ -1,3 +1,13 @@
|
|||
2012-06-12 Ed Schonberg <schonberg@adacore.com>
|
||||
|
||||
* sem_ch3.adb (Analyze_Subtype_Declaration): if an incomplete
|
||||
type is tagged, so is a subtype of it.
|
||||
* sem_ch12.adb (Validate_Actual_Subprogram): implement AI05-0296,
|
||||
concerning freeze rules in the presence of formal incomplete
|
||||
types: a formal abstract subprogram cannot have an incomplete
|
||||
controlling type, and the profile of the actual subprogram does
|
||||
not freeze if it includes an incomplete untagged type.
|
||||
|
||||
2012-06-12 Robert Dewar <dewar@adacore.com>
|
||||
|
||||
* a-direct.adb: Minor reformatting.
|
||||
|
|
|
@ -2664,6 +2664,14 @@ package body Sem_Ch12 is
|
|||
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 @@ package body Sem_Ch12 is
|
|||
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,11 +4340,15 @@ package body Sem_Ch3 is
|
|||
|
||||
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))
|
||||
|
|
Loading…
Reference in New Issue