public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/guojiufu/heads/guojiufu-branch)] [Ada] Insert explicit dereferences when building actual subtype
@ 2020-06-13 2:51 Jiu Fu Guo
0 siblings, 0 replies; only message in thread
From: Jiu Fu Guo @ 2020-06-13 2:51 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2378f3eb81a5a7d4a31cd36ea99d9202eb21f0ef
commit 2378f3eb81a5a7d4a31cd36ea99d9202eb21f0ef
Author: Eric Botcazou <ebotcazou@adacore.com>
Date: Sun Mar 8 19:25:51 2020 +0100
[Ada] Insert explicit dereferences when building actual subtype
2020-06-10 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* sem_util.adb (Copy_And_Maybe_Dereference): New function.
(Build_Access_Record_Constraint): Use it to copy the prefix.
(Build_Actual_Array_Constraint): Likewise.
(Build_Actual_Record_Constraint): Likewise.
Diff:
---
gcc/ada/sem_util.adb | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index d4ff2f1a179..fe6e8c94200 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -1218,6 +1218,10 @@ package body Sem_Util is
-- Similar to previous one, for discriminated components constrained
-- by the discriminant of the enclosing object.
+ function Copy_And_Maybe_Dereference (N : Node_Id) return Node_Id;
+ -- Copy the subtree rooted at N and insert an explicit dereference if it
+ -- is of an access type.
+
-----------------------------------
-- Build_Actual_Array_Constraint --
-----------------------------------
@@ -1239,7 +1243,7 @@ package body Sem_Util is
if Denotes_Discriminant (Old_Lo) then
Lo :=
Make_Selected_Component (Loc,
- Prefix => New_Copy_Tree (P),
+ Prefix => Copy_And_Maybe_Dereference (P),
Selector_Name => New_Occurrence_Of (Entity (Old_Lo), Loc));
else
@@ -1257,7 +1261,7 @@ package body Sem_Util is
if Denotes_Discriminant (Old_Hi) then
Hi :=
Make_Selected_Component (Loc,
- Prefix => New_Copy_Tree (P),
+ Prefix => Copy_And_Maybe_Dereference (P),
Selector_Name => New_Occurrence_Of (Entity (Old_Hi), Loc));
else
@@ -1286,7 +1290,7 @@ package body Sem_Util is
while Present (D) loop
if Denotes_Discriminant (Node (D)) then
D_Val := Make_Selected_Component (Loc,
- Prefix => New_Copy_Tree (P),
+ Prefix => Copy_And_Maybe_Dereference (P),
Selector_Name => New_Occurrence_Of (Entity (Node (D)), Loc));
else
@@ -1322,13 +1326,13 @@ package body Sem_Util is
D_Val := New_Copy_Tree (D);
Set_Expression (D_Val,
Make_Selected_Component (Loc,
- Prefix => New_Copy_Tree (P),
+ Prefix => Copy_And_Maybe_Dereference (P),
Selector_Name =>
New_Occurrence_Of (Entity (Expression (D)), Loc)));
elsif Denotes_Discriminant (D) then
D_Val := Make_Selected_Component (Loc,
- Prefix => New_Copy_Tree (P),
+ Prefix => Copy_And_Maybe_Dereference (P),
Selector_Name => New_Occurrence_Of (Entity (D), Loc));
else
@@ -1342,6 +1346,21 @@ package body Sem_Util is
return Constraints;
end Build_Access_Record_Constraint;
+ --------------------------------
+ -- Copy_And_Maybe_Dereference --
+ --------------------------------
+
+ function Copy_And_Maybe_Dereference (N : Node_Id) return Node_Id is
+ New_N : constant Node_Id := New_Copy_Tree (N);
+
+ begin
+ if Is_Access_Type (Etype (New_N)) then
+ Insert_Explicit_Dereference (New_N);
+ end if;
+
+ return New_N;
+ end Copy_And_Maybe_Dereference;
+
-- Start of processing for Build_Actual_Subtype_Of_Component
begin
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-13 2:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-13 2:51 [gcc(refs/users/guojiufu/heads/guojiufu-branch)] [Ada] Insert explicit dereferences when building actual subtype Jiu Fu Guo
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).