]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Explicitly analyze and expand null array aggregates
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 7 Sep 2023 20:13:51 +0000 (22:13 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 15 Sep 2023 13:01:30 +0000 (15:01 +0200)
Null array aggregates have present but empty lists of expressions and
component associations. This confuses the previous code for ordinary
array aggregates, which assumes that if a list of either expressions or
component associations is present, then it is non-empty.

This patch adds explicit handling for null array aggregates to avoid
assertion failures in code for ordinary array aggregates.

gcc/ada/

* exp_aggr.adb (Build_Array_Aggr_Code): Don't build aggregate code
for null array aggregates.
* sem_aggr.adb (Resolve_Array_Aggregate): Don't examine formatting
of a null array aggregate.

gcc/ada/exp_aggr.adb
gcc/ada/sem_aggr.adb

index d72e27030e50c600b0fa1b83e8182c30e6ac9fc6..165f517c03165a22fd5f4b7eec1662d11a9afdf6 100644 (file)
@@ -1989,7 +1989,10 @@ package body Exp_Aggr is
 
       --  Skip this if no component associations
 
-      if No (Expressions (N)) then
+      if Is_Null_Aggregate (N) then
+         null;
+
+      elsif No (Expressions (N)) then
 
          --  STEP 1 (a): Sort the discrete choices
 
index e929fea3bb6dab3e48acb44594ed5801be25c0c5..597c3ce2dd11e538a852909ed58d25a250581619 100644 (file)
@@ -2081,7 +2081,10 @@ package body Sem_Aggr is
 
       --  STEP 1: make sure the aggregate is correctly formatted
 
-      if Present (Component_Associations (N)) then
+      if Is_Null_Aggregate (N) then
+         null;
+
+      elsif Present (Component_Associations (N)) then
 
          --  Verify that all or none of the component associations
          --  include an iterator specification.