From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: "Marc Poulhiès" <poulhies@adacore.com>
Subject: [COMMITTED] ada: Fix iterated component initialization
Date: Tue, 13 Jun 2023 09:38:25 +0200 [thread overview]
Message-ID: <20230613073825.240197-1-poulhies@adacore.com> (raw)
The call to Resolve_Aggr_Expr may leave references to temporary entities
used to check for the construct legality and meant to be removed.
Using Preanalyze_And_Resolve correctly guarantees that there is no
visible occurrence of such entities.
gcc/ada/
* sem_aggr.adb (Resolve_Iterated_Component_Association): Call
Preanalyze_And_Resolve instead of Resolve_Aggr_Expr except for
aggregate.
Co-authored-by: Ed Schonberg <schonberg@adacore.com>
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_aggr.adb | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 3b2d0347b41..843606ab4a1 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -1862,9 +1862,14 @@ package body Sem_Aggr is
Expr := Expression (N);
- Expander_Mode_Save_And_Set (False);
- Dummy := Resolve_Aggr_Expr (Expr, Single_Elmt => False);
- Expander_Mode_Restore;
+ if Nkind (Expr) = N_Aggregate then
+ -- If the expression is an aggregate, this is a multidimensional
+ -- aggregate where the component type must be propagated downward.
+
+ Dummy := Resolve_Aggr_Expr (Expr, Single_Elmt => False);
+ else
+ Preanalyze_And_Resolve (Expr, Component_Typ);
+ end if;
if Operating_Mode /= Check_Semantics then
Remove_References (Expr);
--
2.40.0
reply other threads:[~2023-06-13 7:38 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=20230613073825.240197-1-poulhies@adacore.com \
--to=poulhies@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).