]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix handling of constrained array declarations in declare-expression
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 31 Jan 2023 13:33:44 +0000 (14:33 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 22 May 2023 08:44:07 +0000 (10:44 +0200)
They need to go through Constrain_Array or else they do not really work.

gcc/ada/

* sem_ch3.adb (Find_Type_Of_Object): In a spec expression, also set
the Scope of the type, and call Constrain_Array for array subtypes.

gcc/ada/sem_ch3.adb

index 66013ca013469f6513dc139731d1c7eebadc5268..7596a59edb98290d1856f93618008bd9f4f9b5ec 100644 (file)
@@ -18417,10 +18417,10 @@ package body Sem_Ch3 is
                Set_Etype  (T, Base_T);
                Mutate_Ekind  (T, Subtype_Kind (Ekind (Base_T)));
                Set_Parent (T, Obj_Def);
+               Set_Scope (T, Current_Scope);
 
                if Ekind (T) = E_Array_Subtype then
-                  Set_First_Index (T, First_Index (Base_T));
-                  Set_Is_Constrained (T);
+                  Constrain_Array (T, Obj_Def, Related_Nod, T, 'P');
 
                elsif Ekind (T) = E_Record_Subtype then
                   Set_First_Entity (T, First_Entity (Base_T));