summaryrefslogtreecommitdiff
path: root/gcc/ada/exp_intr.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-15 16:01:19 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-15 16:01:19 +0000
commit336ba9b63e965018c8176478ce0dc24441306c89 (patch)
tree7fa4caa36aa305bfbec9158228357a6d5641d9aa /gcc/ada/exp_intr.adb
parent51085d5c35a0ade4ede752a15e07d720c4d4ebc5 (diff)
downloadgcc-336ba9b63e965018c8176478ce0dc24441306c89.tar.gz
2005-03-08 Ed Schonberg <schonberg@adacore.com>
* exp_intr.adb (Expand_Unc_Conversion): As a target type, use the type that appears in the instantiation rather than the internal subtype generated in the wrapper package, to avoid anomalies in gigi when the target is derived from a private type whose full view is an access type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96495 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/exp_intr.adb')
-rw-r--r--gcc/ada/exp_intr.adb28
1 files changed, 25 insertions, 3 deletions
diff --git a/gcc/ada/exp_intr.adb b/gcc/ada/exp_intr.adb
index 8f417049520..1efd42bb6b3 100644
--- a/gcc/ada/exp_intr.adb
+++ b/gcc/ada/exp_intr.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2005 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -479,6 +479,7 @@ package body Exp_Intr is
Func : constant Entity_Id := Entity (Name (N));
Conv : Node_Id;
Ftyp : Entity_Id;
+ Ttyp : Entity_Id;
begin
-- Rewrite as unchecked conversion node. Note that we must convert
@@ -500,12 +501,33 @@ package body Exp_Intr is
Analyze_And_Resolve (Conv);
end if;
+ -- The instantiation of Unchecked_Conversion creates a wrapper package,
+ -- and the target type is declared as a subtype of the actual. Recover
+ -- the actual, which is the subtype indic. in the subtype declaration
+ -- for the target type. This is semantically correct, and avoids
+ -- anomalies with access subtypes. For entities, leave type as is.
+
-- We do the analysis here, because we do not want the compiler
-- to try to optimize or otherwise reorganize the unchecked
-- conversion node.
- Rewrite (N, Unchecked_Convert_To (Etype (E), Conv));
- Set_Etype (N, Etype (E));
+ Ttyp := Etype (E);
+
+ if Is_Entity_Name (Conv) then
+ null;
+
+ elsif Nkind (Parent (Ttyp)) = N_Subtype_Declaration then
+ Ttyp := Entity (Subtype_Indication (Parent (Etype (E))));
+
+ elsif Is_Itype (Ttyp) then
+ Ttyp :=
+ Entity (Subtype_Indication (Associated_Node_For_Itype (Ttyp)));
+ else
+ raise Program_Error;
+ end if;
+
+ Rewrite (N, Unchecked_Convert_To (Ttyp, Conv));
+ Set_Etype (N, Ttyp);
Set_Analyzed (N);
if Nkind (N) = N_Unchecked_Type_Conversion then