From: Eric Botcazou <ebotcazou@adacore.com>
To: gcc-patches@gcc.gnu.org
Subject: [Ada] Fix ICE on subprogram defined with null exclusion
Date: Mon, 22 May 2017 10:08:00 -0000 [thread overview]
Message-ID: <5479955.25R4U4yGld@polaris> (raw)
[-- Attachment #1: Type: text/plain, Size: 660 bytes --]
It's a regression present on the mainline and 7 branch: the compiler aborts on
a package containing a declaration of a subprogram taking an access parameter
with null exclusion and a reference to the Access attribute applied to this
subprogram.
Tested on x86_64-suse-linux, applied on the mainline and 7 branch.
2017-05-22 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity): Skip regular processing
for Itypes that are E_Access_Subtype.
<E_Access_Subtype>: Use the DECL of the base type directly.
2017-05-22 Pierre-Marie de Rodat <derodat@adacore.com>
* gnat.dg/specs/not_null1.ads: New test.
--
Eric Botcazou
[-- Attachment #2: not_null1.ads --]
[-- Type: text/x-adasrc, Size: 284 bytes --]
-- { dg-do compile }
package Not_Null1 is
type T is null record;
type T_Access is access all T;
procedure Proc (This : in not null T_Access) is null;
type Proc_Access is access procedure (This : in not null T_Access);
PA : Proc_Access := Proc'Access;
end Not_Null1;
[-- Attachment #3: p.diff --]
[-- Type: text/x-patch, Size: 1612 bytes --]
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c (revision 248321)
+++ gcc-interface/decl.c (working copy)
@@ -310,11 +310,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
/* Contains the list of attributes directly attached to the entity. */
struct attrib *attr_list = NULL;
- /* Since a use of an Itype is a definition, process it as such if it
- is not in a with'ed unit. */
+ /* Since a use of an Itype is a definition, process it as such if it is in
+ the main unit, except for E_Access_Subtype because it's actually a use
+ of its base type, see below. */
if (!definition
&& is_type
&& Is_Itype (gnat_entity)
+ && Ekind (gnat_entity) != E_Access_Subtype
&& !present_gnu_tree (gnat_entity)
&& In_Extended_Main_Code_Unit (gnat_entity))
{
@@ -3823,7 +3825,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
case E_Access_Subtype:
/* We treat this as identical to its base type; any constraint is
meaningful only to the front-end. */
- gnu_type = gnat_to_gnu_type (Etype (gnat_entity));
+ gnu_decl = gnat_to_gnu_entity (Etype (gnat_entity), NULL_TREE, false);
+ saved = true;
/* The designated subtype must be elaborated as well, if it does
not have its own freeze node. But designated subtypes created
@@ -3855,8 +3858,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
gnat_to_gnu_entity (Directly_Designated_Type (gnat_entity),
NULL_TREE, false);
}
-
- maybe_present = true;
break;
/* Subprogram Entities
reply other threads:[~2017-05-22 9:39 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=5479955.25R4U4yGld@polaris \
--to=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/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).