From a36a291399fbcf24d5ea237850b862921ebdec95 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 20 Nov 2020 21:29:13 +0100 Subject: [PATCH] [Ada] Fix internal error on bit-packed array in Volatile_Full_Access record gcc/ada/ * exp_pakd.adb (Expand_Bit_Packed_Element_Set): Fix again packed array type in complex cases where array is Volatile. * exp_util.adb (Remove_Side_Effects): Do not force a renaming to be handled by the back-end. --- gcc/ada/exp_pakd.adb | 11 +++++++++-- gcc/ada/exp_util.adb | 9 +++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb index 07a05a591f4..c90409b5d35 100644 --- a/gcc/ada/exp_pakd.adb +++ b/gcc/ada/exp_pakd.adb @@ -1256,8 +1256,15 @@ package body Exp_Pakd is -- array type on Obj to get lost. So we save the type of Obj, and -- make sure it is reset properly. - New_Lhs := Duplicate_Subexpr (Obj, Name_Req => True); - New_Rhs := Duplicate_Subexpr_No_Checks (Obj); + declare + T : constant Entity_Id := Etype (Obj); + begin + New_Lhs := Duplicate_Subexpr (Obj, Name_Req => True); + New_Rhs := Duplicate_Subexpr_No_Checks (Obj); + Set_Etype (Obj, T); + Set_Etype (New_Lhs, T); + Set_Etype (New_Rhs, T); + end; -- First we deal with the "and" diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 9e08e9c0f28..86e46ea0f1f 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -11798,8 +11798,8 @@ package body Exp_Util is -- If this is a packed array component or a selected component with a -- nonstandard representation, we cannot generate a reference because -- the component may be unaligned, so we must use a renaming and this - -- renaming must be handled by the front end, as the back end may balk - -- at the nonstandard representation (see Exp_Ch2.Expand_Renaming). + -- renaming is handled by the front end, as the back end may balk at + -- the nonstandard representation (see Evaluation_Required in Exp_Ch8). elsif Nkind (Exp) in N_Indexed_Component | N_Selected_Component and then Has_Non_Standard_Rep (Etype (Prefix (Exp))) @@ -11813,8 +11813,7 @@ package body Exp_Util is Subtype_Mark => New_Occurrence_Of (Exp_Type, Loc), Name => Relocate_Node (Exp))); - -- For an expression that denotes a name, we can use a renaming scheme - -- that is handled by the back end, instead of the front end as above. + -- For an expression that denotes a name, we can use a renaming scheme. -- This is needed for correctness in the case of a volatile object of -- a nonvolatile type because the Make_Reference call of the "default" -- approach would generate an illegal access value (an access value @@ -11837,8 +11836,6 @@ package body Exp_Util is Subtype_Mark => New_Occurrence_Of (Exp_Type, Loc), Name => Relocate_Node (Exp))); - Set_Is_Renaming_Of_Object (Def_Id, False); - -- Avoid generating a variable-sized temporary, by generating the -- reference just for the function call. The transformation could be -- refined to apply only when the array component is constrained by a -- 2.30.2