public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [COMMITTED] ada: Fix decoration of iterated component association for GNATprove
Date: Tue, 13 Jun 2023 09:38:44 +0200	[thread overview]
Message-ID: <20230613073844.240700-1-poulhies@adacore.com> (raw)

From: Piotr Trojanek <trojanek@adacore.com>

This patch is an alternative solution for a recent fix in analysis of
iterated component association.

To recap, if the iterated expression is an aggregate, we want to
propagate the component type downward with a call to Resolve_Aggr_Expr;
otherwise we want this expression to be only preanalysed (since the
association might need to be repeatedly evaluated), but also we need to
apply predicate and range checks to the expression itself (these are
required for GNATprove).

It turns out that Resolve_Aggr_Expr already knows how to deal with a
nested aggregate and also works for GNATprove, where it both preanalyzes
the expression and applies necessary checks.

In other words, expression of the iterated component association is now
resolved just like expression of an ordinary array aggregate.

gcc/ada/

	* sem_aggr.adb (Resolve_Iterated_Component_Association): Simply resolve
	the expression.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_aggr.adb | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 843606ab4a1..c6063c78bf6 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -1862,14 +1862,7 @@ package body Sem_Aggr is
 
          Expr := Expression (N);
 
-         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;
+         Dummy := Resolve_Aggr_Expr (Expr, Single_Elmt => False);
 
          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=20230613073844.240700-1-poulhies@adacore.com \
    --to=poulhies@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=trojanek@adacore.com \
    /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).