public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1767] ada: Fix iterated component initialization
@ 2023-06-13  7:34 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2023-06-13  7:34 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:659aeb219401210220a521eccd6ad95620841245

commit r14-1767-g659aeb219401210220a521eccd6ad95620841245
Author: Marc Poulhiès <poulhies@adacore.com>
Date:   Tue Apr 11 09:46:33 2023 +0200

    ada: Fix iterated component initialization
    
    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>

Diff:
---
 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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-13  7:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13  7:34 [gcc r14-1767] ada: Fix iterated component initialization Marc Poulhi?s

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).