https://gcc.gnu.org/g:56ea463808d47cc8bf342b32125e793cfcde472d

commit r15-4917-g56ea463808d47cc8bf342b32125e793cfcde472d
Author: Eric Botcazou <ebotca...@adacore.com>
Date:   Tue Oct 15 21:41:45 2024 +0200

    ada: Propagate resolution status from Resolve_Iterated_Component_Association
    
    The resolution status of Resolve_Aggr_Expr is lost when the routine is
    invoked indirectly from Resolve_Iterated_Component_Association.
    
    gcc/ada/ChangeLog:
    
            * sem_aggr.adb (Resolve_Iterated_Component_Association): Change to
            function returning Boolean and return the result of the call made
            to Resolve_Aggr_Expr.
            (Resolve_Array_Aggregate): Return failure status if the call to
            Resolve_Iterated_Component_Association returns false.

Diff:
---
 gcc/ada/sem_aggr.adb | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 9439d649f2aa..b05b0b267fe7 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -1646,10 +1646,11 @@ package body Sem_Aggr is
       --  node as Expr, since there is no Expression and we need a Sloc for the
       --  error message.
 
-      procedure Resolve_Iterated_Component_Association
+      function Resolve_Iterated_Component_Association
         (N         : Node_Id;
-         Index_Typ : Entity_Id);
-      --  For AI12-061
+         Index_Typ : Entity_Id) return Boolean;
+      --  For AI12-061: resolves iterated component association N of Index_Typ.
+      --  Returns False if resolution fails.
 
       function Subtract (Val : Uint; To : Node_Id) return Node_Id;
       --  Creates a new expression node where Val is subtracted to expression
@@ -2110,9 +2111,9 @@ package body Sem_Aggr is
       -- Resolve_Iterated_Component_Association --
       --------------------------------------------
 
-      procedure Resolve_Iterated_Component_Association
+      function Resolve_Iterated_Component_Association
         (N         : Node_Id;
-         Index_Typ : Entity_Id)
+         Index_Typ : Entity_Id) return Boolean
       is
          Loc  : constant Source_Ptr := Sloc (N);
          Id   : constant Entity_Id  := Defining_Identifier (N);
@@ -2217,10 +2218,6 @@ package body Sem_Aggr is
 
          Resolution_OK := Resolve_Aggr_Expr (Expr, Single_Elmt => False);
 
-         if not Resolution_OK then
-            return;
-         end if;
-
          if Operating_Mode /= Check_Semantics then
             Remove_References (Expr);
             declare
@@ -2235,6 +2232,8 @@ package body Sem_Aggr is
          end if;
 
          End_Scope;
+
+         return Resolution_OK;
       end Resolve_Iterated_Component_Association;
 
       --------------
@@ -2659,7 +2658,11 @@ package body Sem_Aggr is
          Assoc := First (Component_Associations (N));
          while Present (Assoc) loop
             if Nkind (Assoc) = N_Iterated_Component_Association then
-               Resolve_Iterated_Component_Association (Assoc, Index_Typ);
+               if not Resolve_Iterated_Component_Association
+                        (Assoc, Index_Typ)
+               then
+                  return Failure;
+               end if;
 
             elsif Nkind (Assoc) /= N_Component_Association then
                Error_Msg_N

Reply via email to