From: Piotr Trojanek <[email protected]>

Do not try to apply a scalar range check to "others" choice in deep delta array
aggregate. This choice is illegal, but we still need to handle it in expansion.

gcc/ada/ChangeLog:

        * exp_spark.adb (Expand_SPARK_N_Delta_Aggregate): Special case for
        "others" clause.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/exp_spark.adb | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/exp_spark.adb b/gcc/ada/exp_spark.adb
index c536889619c..5df25699618 100644
--- a/gcc/ada/exp_spark.adb
+++ b/gcc/ada/exp_spark.adb
@@ -335,13 +335,16 @@ package body Exp_SPARK is
                   elsif Is_Deep_Choice (Index, Typ) then
                      Apply_Range_Checks (Index);
 
+                  --  In delta_aggregate and Update attribute on array the
+                  --  others_choice is not allowed.
+
+                  elsif Nkind (Index) = N_Others_Choice then
+                     pragma Assert (Serious_Errors_Detected > 0);
+
                   --  Otherwise the index denotes a single expression where
                   --  range checks need to be applied or a subtype name
                   --  (without range constraints) where applying checks is
                   --  harmless.
-                  --
-                  --  In delta_aggregate and Update attribute on array the
-                  --  others_choice is not allowed.
 
                   else pragma Assert (Nkind (Index) in N_Subexpr);
                      Apply_Scalar_Range_Check (Index, Etype (Index_Typ));
-- 
2.53.0

Reply via email to