aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViljar Indus <indus@adacore.com>2024-02-09 12:29:41 +0200
committerMarc Poulhiès <poulhies@adacore.com>2024-05-16 10:49:29 +0200
commitb98e256652c336160afa47bf8735eb4aa3529135 (patch)
treed3634171d086a2bb90de8fca8600234e5cd0e71d
parent81a5815a48b0d392de7ece86bdcc23a2d72aa5bd (diff)
downloadgcc-b98e256652c336160afa47bf8735eb4aa3529135.zip
gcc-b98e256652c336160afa47bf8735eb4aa3529135.tar.gz
gcc-b98e256652c336160afa47bf8735eb4aa3529135.tar.bz2
ada: Fix resolving tagged operations in array aggregates
In the Two_Pass_Aggregate_Expansion we were removing all of the entity links in the Iterator_Specification to avoid reusing the same Iterator_Definition in both loops. However this approach was also breaking the links to calls with dot notation that had been transformed to the regular call notation. In order to circumvent this, explicitly create new identifier definitions when copying the Iterator_Specfications for both of the loops. gcc/ada/ * exp_aggr.adb (Two_Pass_Aggregate_Expansion): Explicitly create new Defining_Iterators for both of the loops.
-rw-r--r--gcc/ada/exp_aggr.adb19
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index bdaca4a..f04dba7 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -5714,6 +5714,7 @@ package body Exp_Aggr is
Iter : Node_Id;
New_Comp : Node_Id;
One_Loop : Node_Id;
+ Iter_Id : Entity_Id;
Size_Expr_Code : List_Id;
Insertion_Code : List_Id := New_List;
@@ -5730,6 +5731,7 @@ package body Exp_Aggr is
while Present (Assoc) loop
Iter := Iterator_Specification (Assoc);
+ Iter_Id := Defining_Identifier (Iter);
Incr := Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Size_Id, Loc),
Expression =>
@@ -5737,10 +5739,16 @@ package body Exp_Aggr is
Left_Opnd => New_Occurrence_Of (Size_Id, Loc),
Right_Opnd => Make_Integer_Literal (Loc, 1)));
+ -- Avoid using the same iterator definition in both loops by
+ -- creating a new iterator for each loop and mapping it over the
+ -- original iterator references.
+
One_Loop := Make_Implicit_Loop_Statement (N,
Iteration_Scheme =>
Make_Iteration_Scheme (Loc,
- Iterator_Specification => New_Copy_Tree (Iter)),
+ Iterator_Specification =>
+ New_Copy_Tree (Iter,
+ Map => New_Elmt_List (Iter_Id, New_Copy (Iter_Id)))),
Statements => New_List (Incr));
Append (One_Loop, Size_Expr_Code);
@@ -5837,6 +5845,7 @@ package body Exp_Aggr is
while Present (Assoc) loop
Iter := Iterator_Specification (Assoc);
+ Iter_Id := Defining_Identifier (Iter);
New_Comp := Make_Assignment_Statement (Loc,
Name =>
Make_Indexed_Component (Loc,
@@ -5869,10 +5878,16 @@ package body Exp_Aggr is
Attribute_Name => Name_Last)),
Then_Statements => New_List (Incr));
+ -- Avoid using the same iterator definition in both loops by
+ -- creating a new iterator for each loop and mapping it over the
+ -- original iterator references.
+
One_Loop := Make_Implicit_Loop_Statement (N,
Iteration_Scheme =>
Make_Iteration_Scheme (Loc,
- Iterator_Specification => Copy_Separate_Tree (Iter)),
+ Iterator_Specification =>
+ New_Copy_Tree (Iter,
+ Map => New_Elmt_List (Iter_Id, New_Copy (Iter_Id)))),
Statements => New_List (New_Comp, Incr));
Append (One_Loop, Insertion_Code);