From 10c257afea5ee3803c4ebf3c0e66d20c66146743 Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Fri, 8 Apr 2022 10:48:10 -0700 Subject: [Ada] Support Ada 2022 null array aggregates Add support for Ada 2022's "[]" null array aggregates (thanks to Ed Schonberg for producing most of this patch). gcc/ada/ * erroutc.ads: Fix a single-character typo in a comment. * exp_aggr.adb: Fix a single-character typo in a comment. Replace several pairs of calls to Low_Bound and High_Bound (which do not handle an identifier that denotes a scalar subtype) with corresponding calls to Get_Index_Bounds (which does handle that case). * par-ch4.adb (P_Aggregate_Or_Paren_Expr): Set the Component_Associations attribute of a null array aggregate to New_List. * sem_aggr.ads: New visible function Is_Null_Array_Aggregate_High_Bound. * sem_aggr.adb (Is_Null_Array_Aggregate_High_Bound, Is_Null_Aggregate, Resolve_Null_Array_Aggregate): New functions. (Resolve_Aggregate): Recognize null array aggregates (using Is_Null_Aggregate) and, when one is recognized, resolve it (using Resolve_Null_Array_Aggregate). Avoid calling Array_Aggr_Subtype for a null array aggregate; the needed subtype is built in Resolve_Null_Array_Aggregate. Do not incorrectly flag a null aggregate (after it is transformed by expansion) as being both positional and named. * sem_attr.adb (Eval_Attribute): Special treatment for null array aggregate high bounds to avoid incorrectly flagging something like Integer'Pred (Integer'First) as an illegal static expression. * sem_eval.adb (Out_Of_Range): Special treatment for null array aggregate high bounds to avoid incorrectly flagging something like Integer'Pred (Integer'First) as an illegal static expression. --- gcc/ada/sem_aggr.ads | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/ada/sem_aggr.ads') diff --git a/gcc/ada/sem_aggr.ads b/gcc/ada/sem_aggr.ads index ee65210..75af8f7 100644 --- a/gcc/ada/sem_aggr.ads +++ b/gcc/ada/sem_aggr.ads @@ -43,4 +43,7 @@ package Sem_Aggr is -- WARNING: There is a matching C declaration of this subprogram in fe.h + function Is_Null_Array_Aggregate_High_Bound (N : Node_Id) return Boolean; + -- Returns True for the high bound of a null array aggregate. + end Sem_Aggr; -- cgit v1.1