diff options
-rw-r--r-- | gcc/ada/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ada/sem_ch10.adb | 28 |
2 files changed, 31 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 9d46f39..be3241e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2019-07-04 Ed Schonberg <schonberg@adacore.com> + + * sem_ch10.adb (Remove_Context_Clauses): Handle properly the + removal of a limited_with_clause which appears in the library + unit oF the main unit, when some other unit in the context has a + regular with_clause on the same unit, to prevent spurious + visibility errors in the subsequent analysis of pending instance + bodies. + 2019-07-04 Hristian Kirtchev <kirtchev@adacore.com> * sem_elab.adb: Add new type Elaboration_Phase_Status along with diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index 407e84f..b8d7c6a 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -6379,22 +6379,38 @@ package body Sem_Ch10 is begin -- Ada 2005 (AI-50217): We remove the context clauses in two phases: - -- limited-views first and regular-views later (to maintain the - -- stack model). + -- limited-views first and regular-views later (to maintain the stack + -- model). -- First Phase: Remove limited_with context clauses Item := First (Context_Items (N)); while Present (Item) loop - -- We are interested only in with clauses which got installed - -- on entry. + -- We are interested only in with clauses that got installed on entry if Nkind (Item) = N_With_Clause and then Limited_Present (Item) - and then Limited_View_Installed (Item) then - Remove_Limited_With_Clause (Item); + if Limited_View_Installed (Item) then + Remove_Limited_With_Clause (Item); + + -- An unusual case: If the library unit of the Main_Unit has + -- a limited with_clause on some unit P and the context somewhere + -- includes a with_clause on P, P has been analyzed. The entity + -- for P is still visible, which in general is harmless because + -- this is the end of the compilation, but it can affect pending + -- instantiations that may have been generated elsewhere, so it + -- it is necessary to remove U from visibility so that inlining + -- and the analysis of instance bodies can proceed cleanly. + + elsif Current_Sem_Unit = Main_Unit + and then Serious_Errors_Detected = 0 + and then not Implicit_With (Item) + then + Set_Is_Immediately_Visible + (Defining_Entity (Unit (Library_Unit (Item))), False); + end if; end if; Next (Item); |