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.
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 --
----------------------
-- 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.
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.