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: 61315 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1182638532EE for ; Thu, 1 Dec 2022 13:56:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1182638532EE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669903014; bh=UpkcXyUPNonJX2UPuMyKO1YfT72opWppDWX13ESE0mE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=yXAyvTQbBBUy1YWc13JfWerJvDhLESLT7Z1rQPfuG7+OM5AJ6wAsCqQfN2wAeXolM 4wv/bU+Q7ldZh1jvGy2q+A6tpbjNfTMPLF5oe+XLJq3NACTszJJiaUW9VVlvBNKhx5 ecZH6vs2kZTZV+EjendCSeT7SjL7YxwS0G5pkN5E= 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-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) 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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 --