]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix couple of remaining incompatibilities with CHERI architecture
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 16 Jan 2025 14:51:00 +0000 (15:51 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 5 Jun 2025 08:18:34 +0000 (10:18 +0200)
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.

gcc/ada/exp_ch9.adb
gcc/ada/exp_pakd.adb

index d75fd3a68256d57ac77e3dde2972fed2e6a5ed48..dd59af970f56927c76dc09411ce8be762c117137 100644 (file)
@@ -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))))))));
 
index 26ef065b529bf6f6737383172c14fdd5e3743fd0..f04016fa811711f06429daf0d587e66d37cf9c78 100644 (file)
@@ -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;