https://gcc.gnu.org/g:9a6162488992afca390e01d4c1ba9264fd10eab8
commit r16-1140-g9a6162488992afca390e01d4c1ba9264fd10eab8 Author: Eric Botcazou <ebotca...@adacore.com> Date: Thu Jan 16 15:51:00 2025 +0100 ada: Fix couple of remaining incompatibilities with CHERI architecture These are the usual problematic patterns in the expanded code. gcc/ada/ChangeLog: * exp_ch9.adb (Build_Dispatching_Requeue): Take 'Tag of the concurrent object instead of doing an unchecked conversion. * exp_pakd.adb (Expand_Packed_Address_Reference): Perform address arithmetic using an operator of System.Storage_Elements. Diff: --- gcc/ada/exp_ch9.adb | 6 ++++-- gcc/ada/exp_pakd.adb | 31 +++++++++++++++++-------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index d75fd3a68256..dd59af970f56 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -9877,7 +9877,7 @@ package body Exp_Ch9 is -- (T => To_Tag_Ptr (Obj'Address).all, -- Position => -- Ada.Tags.Get_Offset_Index - -- (Ada.Tags.Tag (Concval), + -- (Concval._Tag, -- <interface dispatch table position of Ename>)); -- Note that Obj'Address is recursively expanded into a call to @@ -9898,7 +9898,9 @@ package body Exp_Ch9 is Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Get_Offset_Index), Loc), Parameter_Associations => New_List ( - Unchecked_Convert_To (RTE (RE_Tag), Concval), + Make_Attribute_Reference (Loc, + Prefix => Concval, + Attribute_Name => Name_Tag), Make_Integer_Literal (Loc, DT_Position (Entity (Ename)))))))); diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb index 26ef065b529b..f04016fa8117 100644 --- a/gcc/ada/exp_pakd.adb +++ b/gcc/ada/exp_pakd.adb @@ -1526,21 +1526,24 @@ package body Exp_Pakd is Get_Base_And_Bit_Offset (Prefix (N), Base, Offset); + Offset := Unchecked_Convert_To (RTE (RE_Storage_Offset), Offset); + Rewrite (N, - Unchecked_Convert_To (RTE (RE_Address), - Make_Op_Add (Loc, - Left_Opnd => - Unchecked_Convert_To (RTE (RE_Integer_Address), - Make_Attribute_Reference (Loc, - Prefix => Base, - Attribute_Name => Name_Address)), - - Right_Opnd => - Unchecked_Convert_To (RTE (RE_Integer_Address), - Make_Op_Divide (Loc, - Left_Opnd => Offset, - Right_Opnd => - Make_Integer_Literal (Loc, System_Storage_Unit)))))); + Make_Function_Call (Loc, + Name => + Make_Expanded_Name (Loc, + Chars => Name_Op_Add, + Prefix => + New_Occurrence_Of (RTU_Entity (System_Storage_Elements), Loc), + Selector_Name => Make_Identifier (Loc, Name_Op_Add)), + Parameter_Associations => New_List ( + Make_Attribute_Reference (Loc, + Prefix => Base, + Attribute_Name => Name_Address), + Make_Op_Divide (Loc, + Left_Opnd => Offset, + Right_Opnd => + Make_Integer_Literal (Loc, System_Storage_Unit))))); Analyze_And_Resolve (N, RTE (RE_Address)); end Expand_Packed_Address_Reference;