https://gcc.gnu.org/g:29242e3533bf99dfce057d2820ed281f26415eea

commit r17-874-g29242e3533bf99dfce057d2820ed281f26415eea
Author: Steve Baird <[email protected]>
Date:   Thu Feb 26 15:59:07 2026 -0800

    ada: Compiler hangs on a semantically incorrect program.
    
    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.

Diff:
---
 gcc/ada/sem_ch6.adb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index b0eeab5bdb6e..400c3069f9fd 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -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;

Reply via email to