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.
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));