diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-03-04 15:02:32 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-25 09:44:16 +0200 |
commit | c7b84ce699965738b0f2f2d15039c716255f7588 (patch) | |
tree | 0e2a084e5758b6a7011dccc53c35feef5a6ccfc9 | |
parent | 78203700fac6e7e39f5a31e892963172263f8239 (diff) | |
download | gcc-c7b84ce699965738b0f2f2d15039c716255f7588.zip gcc-c7b84ce699965738b0f2f2d15039c716255f7588.tar.gz gcc-c7b84ce699965738b0f2f2d15039c716255f7588.tar.bz2 |
ada: Small tweak to implementation of by-copy semantics for storage models
Get_Actual_Subtype can be used to access the Actual_Designated_Subtype of
explicit dereferences with a storage model. As a side effect, this also
handles the case where the prefix of the dereference is a formal parameter.
gcc/ada/
* exp_ch6.adb (Add_Simple_Call_By_Copy_Code): Use Get_Actual_Subtype
to retrieve the actual subtype for all actuals and do it in only one
place for all unconstrained composite formal types.
-rw-r--r-- | gcc/ada/exp_ch6.adb | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index fce10d5..b240814 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -1969,21 +1969,12 @@ package body Exp_Ch6 is F_Typ := Non_Limited_View (F_Typ); end if; - -- Use the actual designated subtype for a dereference, if any - - if Nkind (Actual) = N_Explicit_Dereference - and then Present (Actual_Designated_Subtype (Actual)) - then - Indic := - New_Occurrence_Of (Actual_Designated_Subtype (Actual), Loc); - -- Use formal type for temp, unless formal type is an unconstrained - -- array, in which case we don't have to worry about bounds checks, - -- and we use the actual type, since that has appropriate bounds. - - elsif Is_Array_Type (F_Typ) and then not Is_Constrained (F_Typ) then - Indic := New_Occurrence_Of (Etype (Actual), Loc); + -- composite, in which case we don't have to worry about checks and + -- we can use the actual type, since that has appropriate bounds. + if Is_Composite_Type (F_Typ) and then not Is_Constrained (F_Typ) then + Indic := New_Occurrence_Of (Get_Actual_Subtype (Actual), Loc); else Indic := New_Occurrence_Of (F_Typ, Loc); end if; @@ -1999,21 +1990,9 @@ package body Exp_Ch6 is -- with the input parameter unless we have an OUT formal or -- this is an initialization call. - -- If the formal is an out parameter with discriminants, the - -- discriminants must be captured even if the rest of the object - -- is in principle uninitialized, because the discriminants may - -- be read by the called subprogram. - if Ekind (Formal) = E_Out_Parameter then Incod := Empty; - if Has_Discriminants (F_Typ) - and then (Nkind (Actual) /= N_Explicit_Dereference - or else No (Actual_Designated_Subtype (Actual))) - then - Indic := New_Occurrence_Of (Etype (Actual), Loc); - end if; - elsif Inside_Init_Proc then -- Skip using the actual as the expression in Decl if we are in |