public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Javier Miranda <miranda@adacore.com>
Subject: [Ada] Crash in interface derivation with null primitive
Date: Mon, 08 Jul 2019 08:19:00 -0000	[thread overview]
Message-ID: <20190708081857.GA80620@adacore.com> (raw)

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

The frontend crashes processing the derivation of a tagged type whose
ultimate ancestor is an interface type I1 that has a null primitive,
implements another interface I2 derived from I2, and does not override
the null primitive.

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

2019-07-08  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* exp_disp.adb (Register_Primitive): When registering a
	primitive in the secondary dispatch table, handle primitive
	inherited through several levels of type derivation (required to
	properly handle inherited 'null' primitive).

gcc/testsuite/

	* gnat.dg/interface9.adb, gnat.dg/interface9_root-child.ads,
	gnat.dg/interface9_root.ads: New testcase.

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

--- gcc/ada/exp_disp.adb
+++ gcc/ada/exp_disp.adb
@@ -7637,7 +7637,7 @@ package body Exp_Disp is
                      Unchecked_Convert_To (RTE (RE_Prim_Ptr),
                        Make_Attribute_Reference (Loc,
                          Prefix         =>
-                           New_Occurrence_Of (Alias (Prim), Loc),
+                           New_Occurrence_Of (Ultimate_Alias (Prim), Loc),
                          Attribute_Name => Name_Unrestricted_Access))));
 
             end if;

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/interface9.adb
@@ -0,0 +1,10 @@
+--  { dg-do compile }
+
+with Interface9_Root.Child;
+procedure Interface9 is
+   package R   is new Interface9_Root (Real => Float);
+   package RC  is new R.Child;
+
+begin
+   null;
+end Interface9;

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/interface9_root-child.ads
@@ -0,0 +1,7 @@
+generic
+package Interface9_Root.Child is
+    type Base_Type is abstract new Base_Interface with null record;
+
+    type Derived_Type is abstract new Base_Type and Derived_Interface
+      with null record; --  Test
+end Interface9_Root.Child;

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/interface9_root.ads
@@ -0,0 +1,10 @@
+generic
+   type Real is digits <>;
+package Interface9_Root is
+   type Base_Interface is limited interface;
+
+   procedure Primitive1 (B : in out Base_Interface) is abstract;
+   procedure Primitive2 (B : in out Base_Interface) is null;
+
+   type Derived_Interface is limited interface and Base_Interface;
+end Interface9_Root;


                 reply	other threads:[~2019-07-08  8:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190708081857.GA80620@adacore.com \
    --to=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=miranda@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).