-- is present.
if Nkind (Comp) = N_Iterated_Element_Association then
-
-- Create a temporary scope to avoid some modifications from
- -- escaping the Analyze call below. The original Tree will be
- -- reanalyzed later.
+ -- escaping the Preanalyze call below. The original tree will
+ -- be reanalyzed later.
Ent := New_Internal_Entity
(E_Loop, Current_Scope, Sloc (Comp), 'L');
Copy := Copy_Separate_Tree (Comp);
Set_Parent (Copy, Parent (Comp));
- Analyze
- (Loop_Parameter_Specification (Copy));
+ Preanalyze (Loop_Parameter_Specification (Copy));
if Present (Iterator_Specification (Copy)) then
Loop_Param_Id :=
end if;
Id_Name := Chars (Loop_Param_Id);
+
else
Copy := Copy_Separate_Tree (Iterator_Specification (Comp));
- Analyze (Copy);
+
+ Preanalyze (Copy);
Loop_Param_Id := Defining_Identifier (Copy);
& "(RM22 4.3.5(24))",
Comp);
else
- Preanalyze_And_Resolve (New_Copy_Tree (Key_Expr), Key_Type);
+ Preanalyze_And_Resolve
+ (Copy_Separate_Tree (Key_Expr), Key_Type);
end if;
end if;
+
End_Scope;
Typ := Etype (Loop_Param_Id);
elsif Present (Iterator_Specification (Comp)) then
-- Create a temporary scope to avoid some modifications from
- -- escaping the Analyze call below. The original Tree will be
- -- reanalyzed later.
+ -- escaping the Preanalyze call below. The original tree will
+ -- be reanalyzed later.
Ent := New_Internal_Entity
(E_Loop, Current_Scope, Sloc (Comp), 'L');
--- /dev/null
+-- PR ada/123371
+-- { dg-do compile }
+-- { dg-options "-gnat2022" }
+
+with Ada.Containers.Ordered_Maps;
+
+package Aggr10 is
+
+ package Maps is new Ada.Containers.Ordered_Maps (Integer, Integer);
+
+ function F return Maps.Map is ([]);
+
+ A : Maps.Map := [for I of Maps.Map'[] => 1]; -- Works
+ B : Maps.Map := [for I of A => 1]; -- Works
+ C : Maps.Map := [for I of B use 1 => 1]; -- Works
+ D : Maps.Map := [for I of F => 1]; -- Works
+
+ X : Maps.Map := [for I of Maps.Map'[] use 1 => 1]; -- Infinite loop
+ Y : Maps.Map := [for I of F use 1 => 1]; -- Infinite loop
+
+end Aggr10;