diff options
Diffstat (limited to 'gcc/ada/sem.adb')
-rw-r--r-- | gcc/ada/sem.adb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb index 2f8192b20cb..047460442fb 100644 --- a/gcc/ada/sem.adb +++ b/gcc/ada/sem.adb @@ -1618,9 +1618,12 @@ package body Sem is Write_Unit_Info (Unit_Num, Item, Withs => True); end if; - -- Main unit should come last + -- Main unit should come last (except in the case where we + -- skipped System_Aux_Id, in which case we missed the things it + -- depends on). - pragma Assert (not Done (Main_Unit)); + pragma Assert + (not Done (Main_Unit) or else Present (System_Aux_Id)); -- We shouldn't do the same thing twice @@ -1757,7 +1760,7 @@ package body Sem is -- If it's a body, then ignore it, unless it's an instance (in -- which case we do the spec), or it's the main unit (in which -- case we do it). Note that it could be both, in which case we - -- do the spec first. + -- do the with_clauses of spec and body first, when N_Package_Body | N_Subprogram_Body => declare @@ -1780,7 +1783,15 @@ package body Sem is if Is_Generic_Instance (Entity) then declare Spec_Unit : constant Node_Id := Library_Unit (CU); + begin + -- Move context of body to that of spec, so it + -- appears before the spec itself, in case it + -- contains nested instances that generate late + -- with_clauses that got attached to the body. + + Append_List + (Context_Items (CU), Context_Items (Spec_Unit)); Do_Unit_And_Dependents (Spec_Unit, Unit (Spec_Unit)); end; |