From: Piotr Trojanek Date: Wed, 23 Aug 2023 14:02:21 +0000 (+0200) Subject: ada: Add guard before querying the type for its interfaces X-Git-Tag: basepoints/gcc-15~6443 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e61fc48f58c16427593ded7fdd0ff49bed897b0;p=thirdparty%2Fgcc.git ada: Add guard before querying the type for its interfaces 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. --- diff --git a/gcc/ada/sem_type.adb b/gcc/ada/sem_type.adb index bbdcd5f24b8a..8579130cdac6 100644 --- a/gcc/ada/sem_type.adb +++ b/gcc/ada/sem_type.adb @@ -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);