diff options
author | Viljar Indus <indus@adacore.com> | 2023-06-14 23:19:49 +0300 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-07-06 13:36:09 +0200 |
commit | 957b48650c8ad893b2b4995b4dcb0b560a0aad3f (patch) | |
tree | a4df5bab543907d434e51a132504ae3e74cbe3c0 | |
parent | d1715f6e7613969d44ab6ab0585eb99200fd62cc (diff) | |
download | gcc-957b48650c8ad893b2b4995b4dcb0b560a0aad3f.zip gcc-957b48650c8ad893b2b4995b4dcb0b560a0aad3f.tar.gz gcc-957b48650c8ad893b2b4995b4dcb0b560a0aad3f.tar.bz2 |
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.
-rw-r--r-- | gcc/ada/exp_util.adb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index c74921e..66e1acb 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)); |