]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix for illegal deep delta array aggregate with others
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 13 Feb 2026 09:07:28 +0000 (10:07 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 28 May 2026 08:52:43 +0000 (10:52 +0200)
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.

gcc/ada/exp_spark.adb

index c536889619c58227539a4f23f13a0bb37d20e03f..5df256996183d31b50b802c12aefef14526a6dc8 100644 (file)
@@ -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));