]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Remove obsolete workaround for back-end limitation
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 18 Oct 2024 15:06:25 +0000 (17:06 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 12 Nov 2024 13:00:45 +0000 (14:00 +0100)
This avoids a strange discrepancy in the handling of constants vs variables.

gcc/ada/ChangeLog:

* sem_aux.ads (Has_Unconstrained_Elements): Delete.
* sem_aux.adb (Has_Unconstrained_Elements): Likewise.
* sem_ch3.adb (Analyze_Object_Declaration): Remove obsolete code.

gcc/ada/sem_aux.adb
gcc/ada/sem_aux.ads
gcc/ada/sem_ch3.adb

index 5edf6675474290fce86ca54a9b7fd1d23c264adf..e7d5c843a5957eaf732ea045271529d294421cb3 100644 (file)
@@ -699,24 +699,6 @@ package body Sem_Aux is
       return Present (Get_Rep_Pragma (E, Nam1, Nam2, Check_Parents));
    end Has_Rep_Pragma;
 
-   --------------------------------
-   -- Has_Unconstrained_Elements --
-   --------------------------------
-
-   function Has_Unconstrained_Elements (T : Entity_Id) return Boolean is
-      U_T : constant Entity_Id := Underlying_Type (T);
-   begin
-      if No (U_T) then
-         return False;
-      elsif Is_Record_Type (U_T) then
-         return Has_Discriminants (U_T) and then not Is_Constrained (U_T);
-      elsif Is_Array_Type (U_T) then
-         return Has_Unconstrained_Elements (Component_Type (U_T));
-      else
-         return False;
-      end if;
-   end Has_Unconstrained_Elements;
-
    ----------------------
    -- Has_Variant_Part --
    ----------------------
index f14a9a141d146df05e126e6c05d5f566b2316350..ae94c1edf0e986fb6f6647e43f70cef6bd58ef53 100644 (file)
@@ -261,10 +261,6 @@ package Sem_Aux is
    --  irregularity compared to other representation aspects, and the cost of
    --  looking up the aspect when needed is small.
 
-   function Has_Unconstrained_Elements (T : Entity_Id) return Boolean;
-   --  True if T has discriminants and is unconstrained, or is an array type
-   --  whose element type Has_Unconstrained_Elements.
-
    function Has_Variant_Part (Typ : Entity_Id) return Boolean;
    --  Return True if the first subtype of Typ is a discriminated record type
    --  which has a variant part. False otherwise.
index b684f69eb8f603af23160cfbf27be346baae1cb8..28fc25d0d0ed1eee1c8c919d7db4ac3cf410012e 100644 (file)
@@ -5213,18 +5213,6 @@ package body Sem_Ch3 is
          Rewrite (Object_Definition (N), New_Occurrence_Of (Act_T, Loc));
          Freeze_Before (N, Act_T);
 
-      elsif Nkind (E) = N_Function_Call
-        and then Constant_Present (N)
-        and then Has_Unconstrained_Elements (Etype (E))
-      then
-         --  The back-end has problems with constants of a discriminated type
-         --  with defaults, if the initial value is a function call. We
-         --  generate an intermediate temporary that will receive a reference
-         --  to the result of the call. The initialization expression then
-         --  becomes a dereference of that temporary.
-
-         Remove_Side_Effects (E);
-
       --  If this is a constant declaration of an unconstrained type and
       --  the initialization is an aggregate, we can use the subtype of the
       --  aggregate for the declared entity because it is immutable.