From fbb076f4dab3541351e4b5ffd5a79099873adae0 Mon Sep 17 00:00:00 2001 From: Steve Baird Date: Thu, 12 Dec 2019 10:03:26 +0000 Subject: [PATCH] [Ada] Improved handling of circular compilation dependencies 2019-12-12 Steve Baird gcc/ada/ * sem_ch10.adb (Install_With_Clause): Check for the case of a circular dependency involving a predefined (or GNAT-defined) unit and handle that case by generating an appropropriate error message. From-SVN: r279299 --- gcc/ada/ChangeLog | 7 +++++++ gcc/ada/sem_ch10.adb | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 6396ee6a5c8..d14f7e3709a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2019-12-12 Steve Baird + + * sem_ch10.adb (Install_With_Clause): Check for the case of a + circular dependency involving a predefined (or GNAT-defined) + unit and handle that case by generating an appropropriate error + message. + 2019-12-12 Gary Dismukes * sem_ch4.adb, sem_res.adb: Minor reformatting. diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index 16f0807fc86..37518df84d6 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -5336,6 +5336,20 @@ package body Sem_Ch10 is Error_Msg_N ("instantiation depends on itself", Name (With_Clause)); + elsif not Analyzed (Uname) + and then Is_Internal_Unit (Current_Sem_Unit) + and then not Is_Visible_Lib_Unit (Uname) + and then No (Scope (Uname)) + then + if Is_Predefined_Unit (Current_Sem_Unit) then + Error_Msg_N + ("predefined unit depends on itself", Name (With_Clause)); + else + Error_Msg_N + ("GNAT-defined unit depends on itself", Name (With_Clause)); + end if; + return; + elsif not Is_Visible_Lib_Unit (Uname) then -- Abandon processing in case of previous errors