This is a small regression present on the mainline and 15 branch: the compiler
aborts on a use clause present in the formal part of a generic unit because of
an oversight in the new inference code for generic actual parameters. The fix
also adds an unrelated missing test to Analyze_Dimension_Array_Aggregate.
Tested on x86-64/Linux, applied on the mainline and 15 branch.
2025-09-22 Eric Botcazou <[email protected]>
PR ada/121968
* sem_ch12.adb (Associations.Find_Assoc): Add guard for clauses.
* sem_dim.adb (Analyze_Dimension_Array_Aggregate): Add test for
N_Iterated_Component_Association nodes.
--
Eric Botcazoudiff --git a/sem_ch12.adb b/sem_ch12.adb
index 0f1746f1ac5..f1f37509a7e 100644
--- a/sem_ch12.adb
+++ b/sem_ch12.adb
@@ -2067,9 +2067,15 @@ package body Sem_Ch12 is
is
begin
for Index in Match.Assocs'Range loop
- if Defining_Entity (Match.Assocs (Index).An_Formal) = F then
- return Index;
- end if;
+ declare
+ An_F : constant Node_Id := Match.Assocs (Index).An_Formal;
+ begin
+ if Nkind (An_F) not in N_Use_Package_Clause | N_Use_Type_Clause
+ and then Defining_Entity (An_F) = F
+ then
+ return Index;
+ end if;
+ end;
end loop;
raise Program_Error; -- it must be present
diff --git a/sem_dim.adb b/sem_dim.adb
index 139ed661f90..822c1284d53 100644
--- a/sem_dim.adb
+++ b/sem_dim.adb
@@ -1273,7 +1273,9 @@ package body Sem_Dim is
-- Get the expression from the component
- if Nkind (Comp) = N_Component_Association then
+ if Nkind (Comp) in N_Component_Association
+ | N_Iterated_Component_Association
+ then
Expr := Expression (Comp);
else
Expr := Comp;