From patchwork Thu Dec 1 13:55:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 28386 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp273259wrr; Thu, 1 Dec 2022 05:58:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf5If/wdzxXOChcadalHAp3v95JudOByQxg8SseMjvOT8BIh9PBs3MsQAA5EpiX9HNMESKkQ X-Received: by 2002:aa7:d0d4:0:b0:46b:fa4:a827 with SMTP id u20-20020aa7d0d4000000b0046b0fa4a827mr19862279edo.30.1669903087673; Thu, 01 Dec 2022 05:58:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669903087; cv=none; d=google.com; s=arc-20160816; b=l+qrUdVn6e7tSpFVyxFcNAZP2Sfw76a551QDlBRFUn2Mxk7o+lwysXRR98Wrn+qYN6 bOH3pvbh+0BXSsexRPBU89ccAdCNk/3UowQnOZcJWHAhSjnLZSwQKs6zeenlGMwvoZ1S ZfFyw4MGSdo74BxY85oNXVmw6xNVuIy2hIGOKXX3mpF+6k8HJ0k1vXbKWrcDpZeXpzsp 3clcmTBIob8rPyQQHBp1Fq2xAAps87lURgjw054ADXedQU4F+qVU3DqUG7lP0AsNvxr0 mflq1HtyygWrkiinecDI9HKEhrtNwpbUBHHV3NE+Y7VgTBiwhTZLcVB2vlB/0+r704KH jvhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=UpkcXyUPNonJX2UPuMyKO1YfT72opWppDWX13ESE0mE=; b=Lbfja12Jb6y9hLHBilVnUV4hDE/CtFJmQExUX0cpvdoE+sWpUZC3bbpDPAIz1bWceF qLcL0UrbRZlbOHw5xqBd0QefM0FvhUtSBEvxnN+1fUDvK3TWIcHVZ2ALbXXY/VhGbWiX cgobHU2MiYKs8twT6oIr2JWtdTV3OAz4WnNYr91KYRAXXu/qAXmjRgQzesSQFI7x2ukP nAfVv3xRZidWYr1H0bGRibGnVviKr4e9W08lo/WrFkWrKPYVXut5dFVI6FOjTGWeCjbU pqrpr0/wi2vg7yyc9R8x5UjCcgY7qAvNU9vGwVT16rKb9v44rTfbgpF5FbgDif5TBAsW xJvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=C4KMwJy5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id be8-20020a1709070a4800b007ae9f42f878si3807473ejc.354.2022.12.01.05.58.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 05:58:07 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=C4KMwJy5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A208E3852C60 for ; Thu, 1 Dec 2022 13:57:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A208E3852C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669903028; bh=UpkcXyUPNonJX2UPuMyKO1YfT72opWppDWX13ESE0mE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=C4KMwJy5HP+BVIz2UIVMuaP0pDSJpw60FkQwsVxasa26UwzMbOg82Bjxq0G62EgF6 NzeSip5+QnaojQ9UcK6snNiWNUY2H6k2BXam4juunkmCDxgJ4WkL/SUfjv/RAYMjTy kMBrEAN7VaO39E1F6X1mgMNIc0HRsWZfcXEJvi4Y= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 Received: by mail-wr1-x436.google.com with SMTP id bs21so2823746wrb.4 for ; Thu, 01 Dec 2022 05:55:35 -0800 (PST) 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-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) 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751020300003204916?= X-GMAIL-MSGID: =?utf-8?q?1751020300003204916?= 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 --