===================================================================
@@ -4510,10 +4510,13 @@
if Building_Static_DT (Typ) then
declare
- Save : constant Boolean := Freezing_Library_Level_Tagged_Type;
+ Saved_FLLTT : constant Boolean :=
+ Freezing_Library_Level_Tagged_Type;
+
+ Formal : Entity_Id;
+ Frnodes : List_Id;
Prim : Entity_Id;
Prim_Elmt : Elmt_Id;
- Frnodes : List_Id;
begin
Freezing_Library_Level_Tagged_Type := True;
@@ -4523,18 +4526,21 @@
Prim := Node (Prim_Elmt);
Frnodes := Freeze_Entity (Prim, Typ);
- declare
- F : Entity_Id;
+ -- We disable this check for abstract subprograms, given that
+ -- they cannot be called directly and thus the state of their
+ -- untagged formals is of no concern. The RM is unclear in any
+ -- case concerning the need for this check, and this topic may
+ -- go back to the ARG.
- begin
- F := First_Formal (Prim);
- while Present (F) loop
- Check_Premature_Freezing (Prim, Typ, Etype (F));
- Next_Formal (F);
+ if not Is_Abstract_Subprogram (Prim) then
+ Formal := First_Formal (Prim);
+ while Present (Formal) loop
+ Check_Premature_Freezing (Prim, Typ, Etype (Formal));
+ Next_Formal (Formal);
end loop;
Check_Premature_Freezing (Prim, Typ, Etype (Prim));
- end;
+ end if;
if Present (Frnodes) then
Append_List_To (Result, Frnodes);
@@ -4543,7 +4549,7 @@
Next_Elmt (Prim_Elmt);
end loop;
- Freezing_Library_Level_Tagged_Type := Save;
+ Freezing_Library_Level_Tagged_Type := Saved_FLLTT;
end;
end if;
===================================================================
@@ -1463,6 +1463,25 @@
-- actuals.
Check_Function_Writable_Actuals (N);
+
+ -- The return type of the function may be incomplete. This can be
+ -- the case if the type is a generic formal, or a limited view. It
+ -- can also happen when the function declaration appears before the
+ -- full view of the type (which is legal in Ada 2012) and the call
+ -- appears in a different unit, in which case the incomplete view
+ -- must be replaced with the full view to prevent subsequent type
+ -- errors.
+
+ if Is_Incomplete_Type (Etype (N))
+ and then Present (Full_View (Etype (N)))
+ then
+ if Is_Entity_Name (Nam) then
+ Set_Etype (Nam, Full_View (Etype (N)));
+ Set_Etype (Entity (Nam), Full_View (Etype (N)));
+ end if;
+
+ Set_Etype (N, Full_View (Etype (N)));
+ end if;
end if;
end Analyze_Call;