diff options
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/exp_util.adb | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 5083817..2c08ea9 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -11530,7 +11530,26 @@ package body Exp_Util is Insert_Action (Exp, E); end if; - -- For expressions that denote names, we can use a renaming scheme. + -- 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). + + elsif Nkind (Exp) in N_Indexed_Component | N_Selected_Component + and then Has_Non_Standard_Rep (Etype (Prefix (Exp))) + then + Def_Id := Build_Temporary (Loc, 'R', Exp); + Res := New_Occurrence_Of (Def_Id, Loc); + + Insert_Action (Exp, + Make_Object_Renaming_Declaration (Loc, + Defining_Identifier => Def_Id, + 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. -- 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 @@ -11553,21 +11572,7 @@ package body Exp_Util is Subtype_Mark => New_Occurrence_Of (Exp_Type, Loc), Name => Relocate_Node (Exp))); - -- If this is a packed reference, or a selected component with - -- a nonstandard representation, a reference to the temporary - -- will be replaced by a copy of the original expression (see - -- Exp_Ch2.Expand_Renaming). Otherwise the temporary must be - -- elaborated by gigi, and is of course not to be replaced in-line - -- by the expression it renames, which would defeat the purpose of - -- removing the side effect. - - if Nkind (Exp) in N_Selected_Component | N_Indexed_Component - and then Has_Non_Standard_Rep (Etype (Prefix (Exp))) - then - null; - else - Set_Is_Renaming_Of_Object (Def_Id, False); - end if; + 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 |