public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Avoid crash in Find_Optional_Prim_Op
@ 2023-07-06 11:38 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-07-06 11:38 UTC (permalink / raw)
  To: gcc-patches; +Cc: Viljar Indus

From: Viljar Indus <indus@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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-06 11:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-06 11:38 [COMMITTED] ada: Avoid crash in Find_Optional_Prim_Op Marc Poulhiès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).