]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix infinite loop with aggregate in generic unit
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 20 Mar 2025 22:29:33 +0000 (23:29 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Tue, 10 Jun 2025 08:58:37 +0000 (10:58 +0200)
Root_Type does not return the same type for the private and the full view of
a derived private tagged type when both derive from an interface type.

gcc/ada/ChangeLog:

* sem_ch12.adb (Copy_Generic_Node): Do not call Root_Type to find
the root type of an aggregate of a derived tagged type.

gcc/ada/sem_ch12.adb

index d93788b779e9ac52d0744f069c7c05cb89b21486..02c7c3696e82fede791d9b0e822fffb4e522f4e3 100644 (file)
@@ -9340,9 +9340,6 @@ package body Sem_Ch12 is
               and then Nkind (Ancestor_Type (N)) in N_Entity
             then
                declare
-                  Root_Typ : constant Entity_Id :=
-                               Root_Type (Ancestor_Type (N));
-
                   Typ : Entity_Id := Ancestor_Type (N);
 
                begin
@@ -9351,7 +9348,7 @@ package body Sem_Ch12 is
                         Switch_View (Typ);
                      end if;
 
-                     exit when Typ = Root_Typ;
+                     exit when Etype (Typ) = Typ;
 
                      Typ := Etype (Typ);
                   end loop;