aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Dismukes <dismukes@adacore.com>2023-11-02 23:36:12 +0000
committerMarc Poulhiès <poulhies@adacore.com>2023-11-21 10:57:43 +0100
commit1f61f81d6ce2fe9c0ee0d833d216b848e0ad0ae4 (patch)
treecafc25e4fe12532a5e2b151c0403b1ff00131d13
parent5a6dbb34c521e79ced35ce778bc86b39f3d348a7 (diff)
downloadgcc-1f61f81d6ce2fe9c0ee0d833d216b848e0ad0ae4.zip
gcc-1f61f81d6ce2fe9c0ee0d833d216b848e0ad0ae4.tar.gz
gcc-1f61f81d6ce2fe9c0ee0d833d216b848e0ad0ae4.tar.bz2
ada: Compiler crash on container aggregate with loop_parameter_specifications
The compiler crashes on a container aggregate with more than one iterated_element_association given by a loop_parameter_specification. In such a case, the tree contains N_Iterated_Component_Association nodes rather than N_Iterated_Element_Association nodes, and the code for handling those needs to obtain the bounds from the Discrete_Choices field of each N_Iterated_Component_Association rather than assuming that the association has a normal list of choices. gcc/ada/ * sem_aggr.adb (Resolve_Container_Aggregate): In the case where Comp is an N_Iterated_Component_Association, pick up Discrete_Choices rather than Choices.
-rw-r--r--gcc/ada/sem_aggr.adb18
1 files changed, 17 insertions, 1 deletions
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index d3f9a77..bc03a07 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -3575,7 +3575,23 @@ package body Sem_Aggr is
end if;
end if;
else
- Choice := First (Choices (Comp));
+
+ -- If Nkind is N_Iterated_Component_Association,
+ -- this corresponds to an iterator_specification
+ -- with a loop_parameter_specification, and we
+ -- have to pick up Discrete_Choices. In this case
+ -- there will be just one "choice", which will
+ -- typically be a range.
+
+ if Nkind (Comp) = N_Iterated_Component_Association
+ then
+ Choice := First (Discrete_Choices (Comp));
+
+ -- Case where there's a list of choices
+
+ else
+ Choice := First (Choices (Comp));
+ end if;
while Present (Choice) loop
Get_Index_Bounds (Choice, Lo, Hi);