]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Detect expansion of iterated component associations into loops
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 21 Jul 2022 19:42:17 +0000 (21:42 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 5 Sep 2022 07:21:04 +0000 (09:21 +0200)
Iterated component associations are expanded into loops, which GNAT
should detect as violating restriction No_Implicit_Loops; same for
iterated element associations and delta array aggregates.

Part of cleanups for correct handling of iterated component associations
in SPARK.

gcc/ada/

* exp_aggr.adb
(Two_Pass_Aggregate_Expansion): Expand into implicit rather than
ordinary loops, to detect violations of restriction
No_Implicit_Loops.
(Generate_Loop): Likewise for delta array aggregates.

gcc/ada/exp_aggr.adb

index 157b01e0ba351dbbf1b9a05b319eca33e2463f34..29bbe768318812aaf2f0a39f02ea9dff9dd32759 100644 (file)
@@ -6430,7 +6430,7 @@ package body Exp_Aggr is
                          Left_Opnd  => New_Occurrence_Of (Size_Id, Loc),
                          Right_Opnd => Make_Integer_Literal (Loc, 1)));
 
-            One_Loop := Make_Loop_Statement (Loc,
+            One_Loop := Make_Implicit_Loop_Statement (N,
               Iteration_Scheme =>
                 Make_Iteration_Scheme (Loc,
                   Iterator_Specification => New_Copy_Tree (Iter)),
@@ -6562,7 +6562,7 @@ package body Exp_Aggr is
                       Attribute_Name => Name_Last)),
                Then_Statements => New_List (Incr));
 
-            One_Loop := Make_Loop_Statement (Loc,
+            One_Loop := Make_Implicit_Loop_Statement (N,
               Iteration_Scheme =>
                 Make_Iteration_Scheme (Loc,
                   Iterator_Specification => Copy_Separate_Tree (Iter)),
@@ -8000,7 +8000,7 @@ package body Exp_Aggr is
          end if;
 
          return
-           Make_Loop_Statement (Loc,
+           Make_Implicit_Loop_Statement (C,
              Iteration_Scheme =>
                Make_Iteration_Scheme (Sl,
                  Loop_Parameter_Specification =>