]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Add guard before querying the type for its interfaces
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 23 Aug 2023 14:02:21 +0000 (16:02 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 5 Sep 2023 11:05:16 +0000 (13:05 +0200)
Fix crash on illegal code, when routine Iface_Present_In_Ancestor is
called on the predefined String type and attempts to examine the list of
interfaces.

gcc/ada/

* sem_type.adb (Iface_Present_In_Ancestor): Only look at the list of
interfaces for types that allow it. The guard is a high-level equivalent
of the entity kinds listed in the preconditon of the Interfaces query.

gcc/ada/sem_type.adb

index bbdcd5f24b8a5abaeb877cf7317d17e9d8bf1510..8579130cdac6502a638f2ee99406853be85407db 100644 (file)
@@ -2578,7 +2578,9 @@ package body Sem_Type is
          end if;
 
          loop
-            if Present (Interfaces (E)) then
+            if Is_Record_Type (E)
+              and then Present (Interfaces (E))
+            then
                Elmt := First_Elmt (Interfaces (E));
                while Present (Elmt) loop
                   AI := Node (Elmt);