]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Small cleanup in aggregate expansion code
authorRonan Desplanques <desplanques@adacore.com>
Fri, 1 Mar 2024 09:31:12 +0000 (10:31 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 17 May 2024 08:20:58 +0000 (10:20 +0200)
This patch moves a statement outside of a loop because it didn't
need to be inside that loop. The behavior of the program is not
affected.

gcc/ada/

* exp_aggr.adb (Flatten): Small cleanup.

gcc/ada/exp_aggr.adb

index 5d2b334722a2f20e0dca848ac22cb8dfe288889b..cff04fc1b79cb40bbc402551e6dcfe722dee19f9 100644 (file)
@@ -4626,6 +4626,14 @@ package body Exp_Aggr is
             Component_Loop : while Present (Elmt) loop
                Expr := Expression (Elmt);
 
+               --  If the expression involves a construct that generates a
+               --  loop, we must generate individual assignments and no
+               --  flattening is possible.
+
+               if Nkind (Expr) = N_Quantified_Expression then
+                  return False;
+               end if;
+
                --  In the case of a multidimensional array, check that the
                --  aggregate can be recursively flattened.
 
@@ -4642,14 +4650,6 @@ package body Exp_Aggr is
                   if Nkind (Choice) = N_Others_Choice then
                      Rep_Count := 0;
 
-                     --  If the expression involves a construct that generates
-                     --  a loop, we must generate individual assignments and
-                     --  no flattening is possible.
-
-                     if Nkind (Expr) = N_Quantified_Expression then
-                        return False;
-                     end if;
-
                      for J in Vals'Range loop
                         if No (Vals (J)) then
                            Vals (J)  := New_Copy_Tree (Expr);