]> gcc.gnu.org Git - gcc.git/commitdiff
ada: Crash on empty aggregate using the Ada 2022 notation
authorJavier Miranda <miranda@adacore.com>
Sun, 12 Mar 2023 12:32:34 +0000 (12:32 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 25 May 2023 07:44:19 +0000 (09:44 +0200)
The compiler crashes processing an empty aggregate initializing
a component of a discriminated record type using the Ada 2022
notation (that is, []).

gcc/ada/

* exp_aggr.adb (Build_Record_Aggr_Code): Protect access to
aggregate components when the aggregate is empty.

gcc/ada/exp_aggr.adb

index f3ad8a9e1ae3546d86ab0d4ef81d77a5c6a11b44..de4d5a785fc2089c0480ab9dfd9f87bfb16e93ea 100644 (file)
@@ -4061,7 +4061,9 @@ package body Exp_Aggr is
                         Decl  : Node_Id;
 
                      begin
-                        if Nkind (First (Choices (Assoc))) = N_Others_Choice
+                        if Present (Assoc)
+                          and then
+                            Nkind (First (Choices (Assoc))) = N_Others_Choice
                         then
                            Decl :=
                              Build_Actual_Subtype_Of_Component
This page took 0.082909 seconds and 5 git commands to generate.