public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Add missing guard before call to Interface_Present_In_Ancestor
@ 2021-10-01  6:14 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-10-01  6:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

Calling the function on an unspecified type may trigger the failure of
the precondition of the Interfaces accessor.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_type.adb (Specific_Type): Check that the type is tagged
	before calling Interface_Present_In_Ancestor on it.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 557 bytes --]

diff --git a/gcc/ada/sem_type.adb b/gcc/ada/sem_type.adb
--- a/gcc/ada/sem_type.adb
+++ b/gcc/ada/sem_type.adb
@@ -3424,7 +3424,8 @@ package body Sem_Type is
       --  Ada 2005 (AI-251): T1 is a concrete type that implements the
       --  class-wide interface T2
 
-      elsif Is_Class_Wide_Type (T2)
+      elsif Is_Tagged_Type (T1)
+        and then Is_Class_Wide_Type (T2)
         and then Is_Interface (Etype (T2))
         and then Interface_Present_In_Ancestor (Typ   => T1,
                                                 Iface => Etype (T2))



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

only message in thread, other threads:[~2021-10-01  6:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01  6:14 [Ada] Add missing guard before call to Interface_Present_In_Ancestor Pierre-Marie de Rodat

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