]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Compiler hangs on a semantically incorrect program.
authorSteve Baird <baird@adacore.com>
Thu, 26 Feb 2026 23:59:07 +0000 (15:59 -0800)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 28 May 2026 08:52:49 +0000 (10:52 +0200)
A homonyms list should be acyclic. Do not introduce a cycle in an error case.

gcc/ada/ChangeLog:

* sem_ch6.adb (Install_Entity): If the entity to be installed is
already installed, assert that an error has already been flagged
and then return without introducing a cycle in the entity's
Homonyms list.

gcc/ada/sem_ch6.adb

index b0eeab5bdb6e3909deeeb35262df71d58c35923b..400c3069f9fdfaf160602513a16f871f8de7676e 100644 (file)
@@ -10932,9 +10932,14 @@ package body Sem_Ch6 is
    procedure Install_Entity (E : Entity_Id) is
       Prev : constant Entity_Id := Current_Entity (E);
    begin
+      if Prev = E then
+         --  avoid creating a Homonym-list cycle
+         pragma Assert (Serious_Errors_Detected > 0);
+         return;
+      end if;
+
       Set_Is_Immediately_Visible (E);
       Set_Current_Entity (E);
-      pragma Assert (Prev /= E);
       Set_Homonym (E, Prev);
    end Install_Entity;