From cc3a298607f8b33c06cbf5163c8eaf07f138d6c0 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Fri, 8 Sep 2017 11:13:07 +0200 Subject: [multiple changes] 2017-09-08 Hristian Kirtchev * sem_util.adb (Copy_Node_With_Replacement): Update the Renamed_Object field of a replicated object renaming declaration. 2017-09-08 Patrick Bernardi * exp_ch9.adb (Is_Pure_Barrier): Allow type conversions and components of objects. Simplified the detection of the Count attribute by identifying the corresponding run-time calls. 2017-09-08 Yannick Moy * exp_ch9.adb, exp_disp.adb, repinfo.adb, sem_ch12.adb, sem_dim.adb, sem_type.adb, sinfo.ads: Minor reformatting. 2017-09-08 Ed Schonberg * freeze.adb (Has_Incomplete_Compoent): New predicate, subsidiary of Freeze_Profile, used to inhibit the freezing of the profile of an expression function declared within a nested package, when some type in the profile depends on a private type declared in an enclosing package. 2017-09-08 Bob Duff * gnat1drv.adb (Gnat1drv): Do not set the Force_ALI_Tree_File flag in the subunit case. It's still OK to set it in the "missing subunits" case, because that won't cause the obsolete .ali files that cause confusion. 2017-09-08 Bob Duff * sinput-l.adb: Remove unused "with Unchecked_Conversion;". It's unclear why this didn't cause a warning. * a-uncdea.ads, a-unccon.ads: Add "Ada." to names in the pragmas. It's unclear why this didn't cause an error. From-SVN: r251869 --- gcc/ada/freeze.adb | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'gcc/ada/freeze.adb') diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index c20beef..8a3bf36 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -3427,6 +3427,60 @@ package body Freeze is R_Type : Entity_Id; Warn_Node : Node_Id; + function Has_Incomplete_Component (T : Entity_Id) return Boolean; + -- If a type includes a private component from an enclosing scope + -- it cannot be frozen yet. This can happen in a package nested + -- within another, when freezing an expression function whose + -- profile depends on a type in some outer scope. Those types will + -- be frozen at a later time in the enclosing unit. + + ------------------------------ + -- Has_Incomplete_Component -- + ------------------------------ + + function Has_Incomplete_Component (T : Entity_Id) return Boolean is + Comp : Entity_Id; + Comp_Typ : Entity_Id; + + begin + if Nkind (N) /= N_Subprogram_Body + or else not Was_Expression_Function (N) + then + return False; + + elsif In_Instance then + return False; + + elsif Is_Record_Type (T) then + Comp := First_Entity (T); + + while Present (Comp) loop + Comp_Typ := Etype (Comp); + if Ekind_In (Comp, E_Component, E_Discriminant) + and then Is_Private_Type (Comp_Typ) + and then No (Full_View (Comp_Typ)) + and then In_Open_Scopes (Scope (Comp_Typ)) + and then Scope (Comp_Typ) /= Current_Scope + then + return True; + end if; + Comp := Next_Entity (Comp); + end loop; + + return False; + + elsif Is_Array_Type (T) then + Comp_Typ := Component_Type (T); + return Is_Private_Type (Comp_Typ) + and then No (Full_View (Comp_Typ)) + and then In_Open_Scopes (Scope (Comp_Typ)) + and then Scope (Comp_Typ) /= Current_Scope; + + else + return False; + end if; + end Has_Incomplete_Component; + begin -- Loop through formals @@ -3446,6 +3500,12 @@ package body Freeze is Set_Etype (Formal, F_Type); end if; + if Has_Incomplete_Component (F_Type) then + Set_Is_Frozen (E, False); + Result := No_List; + return False; + end if; + if not From_Limited_With (F_Type) then Freeze_And_Append (F_Type, N, Result); end if; -- cgit v1.1