public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-4032] ada: Explicitly analyze and expand null array aggregates
@ 2023-09-15 13:05 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2023-09-15 13:05 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d9275e87812a65474be63d565ae4a2eb9a43e9b1

commit r14-4032-gd9275e87812a65474be63d565ae4a2eb9a43e9b1
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Thu Sep 7 22:13:51 2023 +0200

    ada: Explicitly analyze and expand null array aggregates
    
    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.

Diff:
---
 gcc/ada/exp_aggr.adb | 5 ++++-
 gcc/ada/sem_aggr.adb | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index d72e27030e5..165f517c031 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -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
 
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index e929fea3bb6..597c3ce2dd1 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-15 13:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-15 13:05 [gcc r14-4032] ada: Explicitly analyze and expand null array aggregates Marc Poulhi?s

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).