From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Justin Squirek <squirek@adacore.com>
Subject: [Ada] Spurious error on incomplete tagged formal parameter
Date: Thu, 04 Jul 2019 08:51:00 -0000 [thread overview]
Message-ID: <20190704085039.GA38913@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 463 bytes --]
This patch fixes an issue whereby a check for competing controlling
formals led to a spurious dispatching error due to an incomplete type
being used within a subprogram specification.
Tested on x86_64-pc-linux-gnu, committed on trunk
2019-07-04 Justin Squirek <squirek@adacore.com>
gcc/ada/
* sem_disp.adb (Check_Controlling_Formals): Obtain the full view
before type comparison.
gcc/testsuite/
* gnat.dg/tagged2.adb, gnat.dg/tagged2.ads: New testcase.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1176 bytes --]
--- gcc/ada/sem_disp.adb
+++ gcc/ada/sem_disp.adb
@@ -210,6 +210,14 @@ package body Sem_Disp is
Ctrl_Type := Check_Controlling_Type (Etype (Formal), Subp);
if Present (Ctrl_Type) then
+ -- Obtain the full type in case we are looking at an incomplete
+ -- view.
+
+ if Ekind (Ctrl_Type) = E_Incomplete_Type
+ and then Present (Full_View (Ctrl_Type))
+ then
+ Ctrl_Type := Full_View (Ctrl_Type);
+ end if;
-- When controlling type is concurrent and declared within a
-- generic or inside an instance use corresponding record type.
--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/tagged2.adb
@@ -0,0 +1,9 @@
+-- { dg-do compile }
+
+package body Tagged2 is
+
+ procedure Get_Parent
+ (DeviceX : Device;
+ Parent : out Device) is null;
+
+end Tagged2;
--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/tagged2.ads
@@ -0,0 +1,9 @@
+package Tagged2 is
+ type Device;
+
+ procedure Get_Parent
+ (DeviceX : Device;
+ Parent : out Device);
+
+ type Device is tagged null record;
+end Tagged2;
reply other threads:[~2019-07-04 8:51 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=20190704085039.GA38913@adacore.com \
--to=derodat@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=squirek@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).