[COMMITTED] ada: Reject boxes in delta array aggregates

Message ID 20221107084016.151048-1-poulhies@adacore.com
State Repeat Merge
Headers
Series [COMMITTED] ada: Reject boxes in delta array aggregates |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Marc Poulhiès Nov. 7, 2022, 8:40 a.m. UTC
  From: Piotr Trojanek <trojanek@adacore.com>

Implement Ada 2022 4.3.4(11/5), which rejects box compound delimiter <>
in delta record aggregates, just like another rule rejects it in delta
array aggregates.

gcc/ada/

	* sem_aggr.adb (Resolve_Delta_Array_Aggregate): Reject boxes in
	delta array aggregates.

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

---
 gcc/ada/sem_aggr.adb | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 87a8c1a3c40..31ce9cadd94 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -3531,7 +3531,18 @@  package body Sem_Aggr is
                Next (Choice);
             end loop;
 
-            Analyze_And_Resolve (Expression (Assoc), Component_Type (Typ));
+            --  For an array_delta_aggregate, the array_component_association
+            --  shall not use the box symbol <>; RM 4.3.4(11/5).
+
+            pragma Assert
+              (Box_Present (Assoc) xor Present (Expression (Assoc)));
+
+            if Box_Present (Assoc) then
+               Error_Msg_N
+                 ("'<'> in array delta aggregate is not allowed", Assoc);
+            else
+               Analyze_And_Resolve (Expression (Assoc), Component_Type (Typ));
+            end if;
          end if;
 
          Next (Assoc);