]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Syntax error in Ada 2022 array aggregate causes bug box
authorSteve Baird <baird@adacore.com>
Mon, 29 Aug 2022 21:55:14 +0000 (14:55 -0700)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 12 Sep 2022 08:16:50 +0000 (10:16 +0200)
Check for the case where a user writes "in" instead of "of" in an
aggregate like "[for E in Some_Array when Some_Filter (E) => E]".

gcc/ada/

* sem_aggr.adb
(Resolve_Array_Aggregate): Generate an appropriate error message
in the case where an error in the source code leads to an
N_Iterated_Element_Association node in a bad context.

gcc/ada/sem_aggr.adb

index 258e4ad47b6a2ff910aee69fd744c5ffda1eb3fb..5db1fce01b08fa3c45328bcb4b5c4275a0769b51 100644 (file)
@@ -1987,6 +1987,11 @@ package body Sem_Aggr is
          while Present (Assoc) loop
             if Nkind (Assoc) = N_Iterated_Component_Association then
                Resolve_Iterated_Component_Association (Assoc, Index_Typ);
+
+            elsif Nkind (Assoc) /= N_Component_Association then
+               Error_Msg_N
+                 ("invalid component association for aggregate", Assoc);
+               return Failure;
             end if;
 
             Choice := First (Choice_List (Assoc));