https://gcc.gnu.org/g:a5a0d605d8b86156e4e088e64aea16d80655a1a2

commit r15-5126-ga5a0d605d8b86156e4e088e64aea16d80655a1a2
Author: Eric Botcazou <ebotca...@adacore.com>
Date:   Fri Oct 18 17:06:25 2024 +0200

    ada: Remove obsolete workaround for back-end limitation
    
    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.

Diff:
---
 gcc/ada/sem_aux.adb | 18 ------------------
 gcc/ada/sem_aux.ads |  4 ----
 gcc/ada/sem_ch3.adb | 12 ------------
 3 files changed, 34 deletions(-)

diff --git a/gcc/ada/sem_aux.adb b/gcc/ada/sem_aux.adb
index 5edf66754742..e7d5c843a595 100644
--- a/gcc/ada/sem_aux.adb
+++ b/gcc/ada/sem_aux.adb
@@ -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 --
    ----------------------
diff --git a/gcc/ada/sem_aux.ads b/gcc/ada/sem_aux.ads
index f14a9a141d14..ae94c1edf0e9 100644
--- a/gcc/ada/sem_aux.ads
+++ b/gcc/ada/sem_aux.ads
@@ -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.
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index b684f69eb8f6..28fc25d0d0ed 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -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.

Reply via email to