From: Viljar Indus <in...@adacore.com>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/exp_util.adb | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index c74921e1772..66e1acbf65e 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));
-- 
2.40.0

Reply via email to