[Ada] Cleanup SPARK expansion of aggregates with iterated_component_assoc
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 9 Sep 2020 21:55:55 +0000 (23:55 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 26 Oct 2020 08:58:54 +0000 (04:58 -0400)
gcc/ada/

* exp_spark.adb (Expand_SPARK_Delta_Or_Update): Reuse local
constant Expr and the Choice_List routine.
(Expand_SPARK_N_Aggregate): Reuse local constant Expr.

gcc/ada/exp_spark.adb

index f6ef865..5e1fac2 100644 (file)
@@ -227,7 +227,7 @@ package body Exp_SPARK is
 
                if Nkind (Assoc) = N_Iterated_Component_Association then
                   Push_Scope (Scope (Defining_Identifier (Assoc)));
-                  Analyze_And_Resolve (Expression (Assoc), Comp_Type);
+                  Analyze_And_Resolve (Expr, Comp_Type);
                end if;
 
                if Is_Scalar_Type (Comp_Type) then
@@ -240,11 +240,7 @@ package body Exp_SPARK is
                   End_Scope;
                end if;
 
-               Index :=
-                 First
-                   (if Nkind (Assoc) = N_Iterated_Component_Association
-                    then Discrete_Choices (Assoc)
-                    else Choices (Assoc));
+               Index     := First (Choice_List (Assoc));
                Index_Typ := First_Index (Typ);
 
                while Present (Index) loop
@@ -399,7 +395,7 @@ package body Exp_SPARK is
 
                Push_Scope (Scope (Defining_Identifier (Assoc)));
                Enter_Name (Defining_Identifier (Assoc));
-               Analyze_And_Resolve (Expression (Assoc), Comp_Type);
+               Analyze_And_Resolve (Expr, Comp_Type);
 
                if Is_Scalar_Type (Comp_Type) then
                   Apply_Scalar_Range_Check (Expr, Comp_Type);