From: Viljar Indus Date: Wed, 14 Jun 2023 20:19:49 +0000 (+0300) Subject: ada: Avoid crash in Find_Optional_Prim_Op X-Git-Tag: basepoints/gcc-15~7782 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=957b48650c8ad893b2b4995b4dcb0b560a0aad3f;p=thirdparty%2Fgcc.git ada: Avoid crash in Find_Optional_Prim_Op Find_Optional_Prim_Op can crash when the Underlying_Type is Empty. This can happen when you are dealing with a structure type with a private part that does not have its Full_View set yet. gcc/ada/ * exp_util.adb (Find_Optional_Prim_Op): Stop deriving primitive operation if there is no underlying type to derive it from. --- diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index c74921e1772a..66e1acbf65ee 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -6291,6 +6291,11 @@ package body Exp_Util is Typ := Underlying_Type (Typ); + -- We cannot find the operation if there is no full view available. + if Typ = Empty then + return Empty; + end if; + -- Loop through primitive operations Prim := First_Elmt (Primitive_Operations (Typ));