From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Gary Dismukes <dismukes@adacore.com>
Subject: [COMMITTED] ada: Compiler crash on container aggregate with loop_parameter_specifications
Date: Tue, 21 Nov 2023 11:00:58 +0100 [thread overview]
Message-ID: <20231121100058.1965264-1-poulhies@adacore.com> (raw)
From: Gary Dismukes <dismukes@adacore.com>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_aggr.adb | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index d3f9a773191..bc03a079f5a 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);
--
2.42.0
reply other threads:[~2023-11-21 10:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231121100058.1965264-1-poulhies@adacore.com \
--to=poulhies@adacore.com \
--cc=dismukes@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).