From: Eric Botcazou <ebotcazou@adacore.com>
To: gcc-patches@gcc.gnu.org
Subject: Fix PR ada/62235
Date: Tue, 05 Sep 2017 09:49:00 -0000 [thread overview]
Message-ID: <6220290.NY0sf8PeYM@polaris> (raw)
[-- Attachment #1: Type: text/plain, Size: 493 bytes --]
Tested on x86_64-suse-linux, applied on mainline and 7 branch.
2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
PR ada/62235
* gcc-interface/decl.c (gnat_to_gnu_entity): Skip regular processing
for Itypes that are E_Record_Subtype with a cloned subtype.
<E_Record_Subtype>: Use the DECL of the cloned type directly, if any.
2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/incomplete5.ad[sb]: New test.
* gnat.dg/incomplete5_pkg.ad[sb]: New helper.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1143 bytes --]
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c (revision 251700)
+++ gcc-interface/decl.c (working copy)
@@ -312,11 +312,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
/* 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. */
+ of its base type, and for E_Record_Subtype with cloned subtype because
+ it's actually a use of the cloned subtype, see below. */
if (!definition
&& is_type
&& Is_Itype (gnat_entity)
- && Ekind (gnat_entity) != E_Access_Subtype
+ && !(kind == E_Access_Subtype
+ || (kind == E_Record_Subtype
+ && Present (Cloned_Subtype (gnat_entity))))
&& !present_gnu_tree (gnat_entity)
&& In_Extended_Main_Code_Unit (gnat_entity))
{
@@ -3411,7 +3414,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
{
gnu_decl = gnat_to_gnu_entity (Cloned_Subtype (gnat_entity),
NULL_TREE, false);
- maybe_present = true;
+ saved = true;
break;
}
[-- Attachment #3: incomplete5.adb --]
[-- Type: text/x-adasrc, Size: 167 bytes --]
-- { dg-do compile }
package body Incomplete5 is
function Get (O: Base_Object) return Integer is
begin
return Get_Handle(O).I;
end;
end Incomplete5;
[-- Attachment #4: incomplete5.ads --]
[-- Type: text/x-adasrc, Size: 357 bytes --]
with Incomplete5_Pkg;
package Incomplete5 is
type Rec1 is private;
type Rec2 is private;
package My_G is new Incomplete5_Pkg (Rec1);
use My_G;
function Get (O: Base_Object) return Integer;
private
type Rec1 is record
I : Integer;
end record;
type Rec2 is record
A : Access_Type;
end record;
end Incomplete5;
[-- Attachment #5: incomplete5_pkg.adb --]
[-- Type: text/x-adasrc, Size: 284 bytes --]
package body Incomplete5_Pkg is
function Get_Handle (Object: Base_Object) return Access_Type is
begin
return Object.Handle;
end;
function From_Handle (Handle: Access_Type) return Base_Object is
begin
return (Handle=>Handle);
end;
end Incomplete5_Pkg;
[-- Attachment #6: incomplete5_pkg.ads --]
[-- Type: text/x-adasrc, Size: 333 bytes --]
generic
type Record_Type;
package Incomplete5_Pkg is
type Access_Type is access Record_Type;
type Base_Object is tagged record
Handle: Access_Type;
end record;
function Get_Handle(Object: Base_Object) return Access_Type;
function From_Handle(Handle: Access_Type) return Base_Object;
end Incomplete5_Pkg;
reply other threads:[~2017-09-05 9:49 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=6220290.NY0sf8PeYM@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).