From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 2AC86385841E; Thu, 1 Dec 2022 13:55:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2AC86385841E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669902900; bh=9prCyZLIDBNw+QbSdhg0r6LBf/OX8h9yUKdDTWF3pws=; h=From:To:Subject:Date:From; b=S8hb6H7c7O/ltX7rZaHTUh//v27xzwGVwqLho1+baua0g3voCVBTnRucpnmWdYsxn rmS9BllAut+q3ZihYgsxiaBv9vcuOl3/DWURjfyLMsrPiV6QIBz6LjbU22iXjwQQY2 WUdHLFzi5xZ4ypnZqMJXdjPyFOehfo2oqfDEvXxw= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4441] ada: Use the address type of a Storage_Model_Type for 'Address X-Act-Checkin: gcc X-Git-Author: Gary Dismukes X-Git-Refname: refs/heads/master X-Git-Oldrev: eeba836bf3dc26ea858020bc19e2c1a1606b75dd X-Git-Newrev: 8e56d311d380cbdc37a910fa96c06c6eb91973d7 Message-Id: <20221201135500.2AC86385841E@sourceware.org> Date: Thu, 1 Dec 2022 13:55:00 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8e56d311d380cbdc37a910fa96c06c6eb91973d7 commit r13-4441-g8e56d311d380cbdc37a910fa96c06c6eb91973d7 Author: Gary Dismukes Date: Fri Nov 18 17:43:36 2022 -0500 ada: Use the address type of a Storage_Model_Type for 'Address When an Address attribute applies to an object that is a dereference of an access value whose type has aspect Designated_Storage_Model, the attribute will now be treated as having the address type associated with the Storage_Model_Type of the access type's associated Storage_Model object instead of being of type System.Address. gcc/ada/ * sem_attr.adb (Analyze_Attribute, Attribute_Address): In the case where the attribute's prefix is a dereference of a value of an access type that has aspect Designated_Storage_Model (or a renaming of such a dereference), set the attribute's type to the corresponding Storage_Model_Type's associated address type rather than System.Address. Diff: --- gcc/ada/sem_attr.adb | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 4c76b9344c2..cca6f6f8c7d 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -3430,7 +3430,34 @@ package body Sem_Attr is Check_E0; Address_Checks; Check_Not_Incomplete_Type; - Set_Etype (N, RTE (RE_Address)); + + -- If the prefix is a dereference of a value whose associated access + -- type has been specified with aspect Designated_Storage_Model, then + -- use the associated Storage_Model_Type's address type as the type + -- of the attribute. Otherwise we use System.Address as usual. This + -- isn't normally legit for a predefined attribute, but this is for + -- our own extension to addressing and currently requires extensions + -- to be enabled (such as with -gnatX0). + + declare + Prefix_Obj : constant Node_Id := Get_Referenced_Object (P); + Addr_Type : Entity_Id := RTE (RE_Address); + begin + if Nkind (Prefix_Obj) = N_Explicit_Dereference then + declare + P_Type : constant Entity_Id := Etype (Prefix (Prefix_Obj)); + + use Storage_Model_Support; + begin + if Has_Designated_Storage_Model_Aspect (P_Type) then + Addr_Type := Storage_Model_Address_Type + (Storage_Model_Object (P_Type)); + end if; + end; + end if; + + Set_Etype (N, Addr_Type); + end; ------------------ -- Address_Size --