]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix incorrect handling of Aggregate aspect
authorMarc Poulhiès <poulhies@adacore.com>
Tue, 28 Feb 2023 16:10:29 +0000 (17:10 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 13 Mar 2024 15:34:54 +0000 (16:34 +0100)
This change fixes 2 incorrect handlings of the aspect.
The arguments are now correctly resolved and the aspect is rejected on
non array types.

gcc/ada/

* sem_ch13.adb (Analyze_One_Aspect): Mark Aggregate aspect as
needing delayed resolution and reject the aspect on non-array
type.

gcc/ada/sem_ch13.adb

index b81b6b02e1d3494ce3bcf2c799e14f9ff146e358..317c4841d87234c6c4264eb7f080e1f1fe6d093e 100644 (file)
@@ -2921,10 +2921,10 @@ package body Sem_Ch13 is
             end case;
 
             if Delay_Required
-
                and then (A_Id = Aspect_Stable_Properties
                           or else A_Id = Aspect_Designated_Storage_Model
-                          or else A_Id = Aspect_Storage_Model_Type)
+                          or else A_Id = Aspect_Storage_Model_Type
+                          or else A_Id = Aspect_Aggregate)
                --  ??? It seems like we should do this for all aspects, not
                --  just these, but that causes as-yet-undiagnosed regressions.
 
@@ -4211,6 +4211,12 @@ package body Sem_Ch13 is
                   Aitem := Empty;
 
                when Aspect_Aggregate =>
+                  if Is_Array_Type (E) then
+                     Error_Msg_N
+                       ("aspect% can only be applied to non-array type", Id);
+                     goto Continue;
+                  end if;
+
                   Validate_Aspect_Aggregate (Expr);
                   Record_Rep_Item (E, Aspect);
                   goto Continue;