From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 621663858C50 for ; Thu, 1 Dec 2022 13:55:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 621663858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x436.google.com with SMTP id bs21so2823746wrb.4 for ; Thu, 01 Dec 2022 05:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UpkcXyUPNonJX2UPuMyKO1YfT72opWppDWX13ESE0mE=; b=Xvc/fp99M3EBJq/oqUw5G9M7oKywFnKKmqylvJPy5OOqhzEVaKz0VaZIC052jtSLCX L3PtbuIVaIIr63AApJX5H1BkTK8uV6wKEwDZATBmgtzm/syTQa3G7aLjJvcYJrZ0F5Kp MaoCwO3oieZ6tCCcVXku1q3xU263J5LJ64NsAyVb7wqlNeUz99AR/uRMR4LSv7Q02HW7 iuyEMfhAHq/Y0i3fLoCc1Lha2m3gFDcgfFxP3VR37qqgWDER/G7TuBHvL0DGEeLyYdKA g85ZRtGWEnhPvIlmutgOFj8+OaicUbGLGoRIY3S0Bvr59QEad/JooFRLxhVzD4ba2y1V m77g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UpkcXyUPNonJX2UPuMyKO1YfT72opWppDWX13ESE0mE=; b=KaQvxsym3Yih2j1jxU2ntOAQ8PSEFjHreTXgNpFDJgtfKwi4E9UYW3j48eDVxEMAs+ 6JMQkMgxH70z2xDrlawQxob4PmeviyTDXSZ8FxoY2iqwHD7h9qkpxIm7LBk1OhYSS/2h QAJ1RsSSFtQ80wYX+V4SU0VHAFo8v5QdIZbOEFLoWg3CzFBMcs/r1+Hq7DP00s3gK5Th dYuQgH9cE8QdEaomsp+fBTO8umE8jLu2TwF7rs5AVRyFhXd8Wu22N2esBH2H0zfWR6k5 YoLrgx71/W5oCdWRMXiMMubXlPdW4BoeNjHwiMqtwTy/y+Ya0qx8B0GRFoBnVqcugsAX N/Uw== X-Gm-Message-State: ANoB5pkVCi+Wsp/cmeCZWEC8LWeAAsKSsJdw3TZjzplo0U6sbXlQoNG4 B20OgznOMN/LUIgl5kqH5FTF119zV+/Q4Q== X-Google-Smtp-Source: AA0mqf5JGDe2kW9PbmYEcOzv27x7VCqwnqFdN9CqJ3PdIhhw/7Ixcjd47ib+GtYGP0iLGVEHbp1Q1w== X-Received: by 2002:a5d:65c9:0:b0:241:bd29:6a73 with SMTP id e9-20020a5d65c9000000b00241bd296a73mr39463558wrw.499.1669902935016; Thu, 01 Dec 2022 05:55:35 -0800 (PST) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id hg6-20020a05600c538600b003a6125562e1sm5385131wmb.46.2022.12.01.05.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 05:55:34 -0800 (PST) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED] ada: Use the address type of a Storage_Model_Type for 'Address Date: Thu, 1 Dec 2022 14:55:32 +0100 Message-Id: <20221201135532.458039-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Gary Dismukes 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. Tested on x86_64-pc-linux-gnu, committed on master. --- 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 -- -- 2.34.1