summaryrefslogtreecommitdiffstats
path: root/gcc/ada/exp_ch5.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/exp_ch5.adb')
-rw-r--r--gcc/ada/exp_ch5.adb8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index 54dea9ad5e0..5203885712d 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -2905,7 +2905,7 @@ package body Exp_Ch5 is
Loc : constant Source_Ptr := Sloc (N);
Container : constant Node_Id := Name (I_Spec);
- Container_Typ : constant Entity_Id := Etype (Container);
+ Container_Typ : constant Entity_Id := Base_Type (Etype (Container));
Cursor : Entity_Id;
Iterator : Entity_Id;
New_Loop : Node_Id;
@@ -2990,7 +2990,7 @@ package body Exp_Ch5 is
-- declare
-- -- the block is added when Element_Type is controlled
- -- Obj : Pack.Element_Type := Element (Iterator);
+ -- Obj : Pack.Element_Type := Element (Cursor);
-- -- for the "of" loop form
-- begin
-- <original loop statements>
@@ -3156,9 +3156,11 @@ package body Exp_Ch5 is
-- X in Iterate (S) : type of iterator is type of explicitly
-- given Iterate function, and the loop variable is the cursor.
+ -- It will be assigned in the loop and must be a variable.
else
Cursor := Id;
+ Set_Ekind (Cursor, E_Variable);
end if;
Iterator := Make_Temporary (Loc, 'I');
@@ -3247,6 +3249,8 @@ package body Exp_Ch5 is
Subtype_Mark => New_Occurrence_Of (Iter_Type, Loc),
Name => Relocate_Node (Name (I_Spec)));
+ -- Create declaration for cursor.
+
Decl2 :=
Make_Object_Declaration (Loc,
Defining_Identifier => Cursor,
OpenPOWER on IntegriCloud