[Ada] Fix expansion of quantified expressions as part of "others" associations
authorEd Schonberg <schonberg@adacore.com>
Fri, 25 May 2018 09:04:59 +0000 (09:04 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Fri, 25 May 2018 09:04:59 +0000 (09:04 +0000)
2018-05-25  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* exp_aggr.adb (Flatten): A quantified expression cannot be duplicated
in an others clause to prevent visibility issues with the generated
loop variable.
(Component_OK_For_Backend): Return false for a quantified expression.
(Check_Static_Component): Ditto.

From-SVN: r260737

gcc/ada/ChangeLog
gcc/ada/exp_aggr.adb

index 73dec9d74d637d6f05727729ce626bbc3d04cbbd..dfe117ad9c592148b6c0b3f0b58036c5d362c7de 100644 (file)
@@ -1,3 +1,11 @@
+2018-05-25  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_aggr.adb (Flatten): A quantified expression cannot be duplicated
+       in an others clause to prevent visibility issues with the generated
+       loop variable.
+       (Component_OK_For_Backend): Return false for a quantified expression.
+       (Check_Static_Component): Ditto.
+
 2018-05-25  Hristian Kirtchev  <kirtchev@adacore.com>
 
        * libgnat/s-secsta.adb (SS_Allocate): Reimplemented.
index 81d35533b18e072b49a0e358cf39443a6ba13c20..f4619a8b9e12540e2fcdd643475a9142262cf30d 100644 (file)
@@ -4373,6 +4373,7 @@ package body Exp_Aggr is
                  or else not Compile_Time_Known_Aggregate (Expression (Expr))
                  or else Expansion_Delayed (Expression (Expr))
                  or else Nkind (Expr) = N_Iterated_Component_Association
+                 or else Nkind (Expr) = N_Quantified_Expression
                then
                   Static_Components := False;
                   exit;
@@ -4523,10 +4524,20 @@ package body Exp_Aggr is
 
                   --  If we have an others choice, fill in the missing elements
                   --  subject to the limit established by Max_Others_Replicate.
+                  --  If the expression involves a construct that generates
+                  --  a loop, we must generate individual assignmentw and
+                  --  no flattening is possible.
 
                   if Nkind (Choice) = N_Others_Choice then
                      Rep_Count := 0;
 
+                     if Nkind_In  (Expression (Elmt),
+                         N_Quantified_Expression,
+                         N_Iterated_Component_Association)
+                     then
+                        return False;
+                     end if;
+
                      for J in Vals'Range loop
                         if No (Vals (J)) then
                            Vals (J) := New_Copy_Tree (Expression (Elmt));
@@ -7235,6 +7246,10 @@ package body Exp_Aggr is
                Static_Components := False;
                return False;
 
+            elsif Nkind (Expr_Q) = N_Quantified_Expression then
+               Static_Components := False;
+               return False;
+
             elsif Possible_Bit_Aligned_Component (Expr_Q) then
                Static_Components := False;
                return False;