From patchwork Thu May 25 08:06:15 2023 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: 98878 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp205342vqr; Thu, 25 May 2023 01:32:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ70SMISZqlZpggv1zzZPEj9vT8jhQYJcDVG2D4nBuQhooDl3RdFyzqmXYQhsDzFsDLSnPIZ X-Received: by 2002:a17:907:5c1:b0:968:db2f:383 with SMTP id wg1-20020a17090705c100b00968db2f0383mr803031ejb.53.1685003543125; Thu, 25 May 2023 01:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685003543; cv=none; d=google.com; s=arc-20160816; b=mg677awlioSPBgZ7JJBBcCfdCuk86KhwUrgmOJd54UWsPoozLphJG+oUg3uYl9NiEU rUfRpyWimuepffBx6HhnMNzjpov1eiWESlAZJ80loYDYo8ot1NUIG3JxzObzpe3gllUy s0XBWv5OggQP+BbjoXB7UHEer4nUpP2Dg/LyFSs15B2EFyULz7n37OPqLq4jwPVbb0UA ncAF0i9LksK3oXqxQoeyIdq5NPOfxCl9+ze42CuXrhahLjtpkO/bT/lYs4fakJTq5fIP GZrHfPf/DFiG/wHwKf47xiQ/H3emZky0EWd2K4vtkQamG7VQha2CLl71Us84KNFZ6/jG Jh3Q== 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=p/wyzVR57UMJpK3ST0JqWoA/iqUnR17jvHXEBPJ4Q5g=; b=u5IyXYxaV2cWbgT89D9avOmpUrNh0JsAg2UPub6SuWy4Rb/asliZVSwHvi8ZK9dcEK z5/1ojRLZkWDRoP+EZBTIkq0Kj8plF3XhL+VVMd+ubtHP9WAMcjUfNWTFO1DXldV8h9q PHoJG7xONW5cs9mAFsHfJBgIbUpyhfd3T/cbZMSmtQGQKAe35OnPedmwkoxrLy+yBOSP nnjEUjQ6OiJ2JrZC8Pkqi1cpSlBhSZZ9UsQzULutppuihs/UFh7KZKlWf7bHC/NvFJvZ 0d/J5f1fY74e8vJtxrYHMjmekJwQMG8vE1xId4s3NAQshjVgbXRwn2+aB3aYBVDhFI9r jjCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xaV+dS+N; 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 jg4-20020a170907970400b0096621c999c5si764784ejc.288.2023.05.25.01.32.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 01:32:23 -0700 (PDT) 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=xaV+dS+N; 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 5DE1F3945C12 for ; Thu, 25 May 2023 08:22:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DE1F3945C12 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685002934; bh=p/wyzVR57UMJpK3ST0JqWoA/iqUnR17jvHXEBPJ4Q5g=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xaV+dS+NaqK76KvYdXNyZU1MK7fR1xMRlr2Q/UF/spvVShJBHu/sN+f9QWeR4qYiO JKekMBQ7vsqJNg2w85zi87HH3h8l4mNtE8n75xDGcoi2sMwggOAfQoiT55GOe27WJV H6ynoXh+6ziMhwvjn62+DZWiyrKiVIndgFRxk72M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 769973853D32 for ; Thu, 25 May 2023 08:06:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 769973853D32 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3093a7b71fbso1726355f8f.2 for ; Thu, 25 May 2023 01:06:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685001976; x=1687593976; 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=p/wyzVR57UMJpK3ST0JqWoA/iqUnR17jvHXEBPJ4Q5g=; b=RwcSB9GMkVJ2mwwW1PB1A8DxytiXI+LFfjFzHxmWFWwYqJYvNd0kn0mXT0VJt2wOsD CqrSf9Kb1PV0TXoaUJHVxfpclW+wnmKioUbOuYwwXL+VRYzuWZyzgEePiYC0qg6jlMfv BGwxFcVurZpEPDNTVMZNavLHot8vWks24Sk6MGL9f6IPuBst6cN2B7teyzvmKQmO12R0 4/7mxBG6vJEjXhHRYE+ju7ztmywA6eYfUo7tB/1BrUFzl4r80Gmf89QMpps0DFYfz7g2 dEyqVcN+T3mWubdXNbjNJnlOhOjCSszKEP7BQVKLoPTWKZNebHHJTu3Z45SJXe9rFWC4 nyMQ== X-Gm-Message-State: AC+VfDzWk+lcdqfqpz122JkX7aWPjBNYKyhHAVELzNWLyLuU1TbpyQRd G6PXKpzumw1lJvXx2iFoYv3tW7u2J94HCyeC1PyAjA== X-Received: by 2002:adf:fe42:0:b0:309:3a83:cf43 with SMTP id m2-20020adffe42000000b003093a83cf43mr1575233wrs.27.1685001976396; Thu, 25 May 2023 01:06:16 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id q9-20020a5d6589000000b003062c609115sm904143wru.21.2023.05.25.01.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 01:06:15 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Minor adjustments to Standard_Address Date: Thu, 25 May 2023 10:06:15 +0200 Message-Id: <20230525080615.1957429-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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, T_SCC_BODY_TEXT_LINE 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?1766854275218568322?= X-GMAIL-MSGID: =?utf-8?q?1766854275218568322?= From: Eric Botcazou Standard_Address is an internal entity that is meant to be a clone of System.Address built at compilation startup. It needs to be seen as a bona-fide address by the code generator. For the sake of completeness, it is also given its modulus, although this does not matter in practice. gcc/ada/ * cstand.adb (Create_Standard): Set the Is_Descendant_Of_Address flag on Standard_Address. * freeze.adb (Freeze_Entity): Copy the modulus of System.Address onto Standard_Address. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/cstand.adb | 2 ++ gcc/ada/freeze.adb | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gcc/ada/cstand.adb b/gcc/ada/cstand.adb index fbd5888b198..d4a420deda9 100644 --- a/gcc/ada/cstand.adb +++ b/gcc/ada/cstand.adb @@ -1370,9 +1370,11 @@ package body CStand is -- Standard_Address is not user visible, but is used internally. It is -- an unsigned type mod 2**System_Address_Size with System.Address size. + -- We flag it as Is_Descendant_Of_Address for code generation purposes. Standard_Address := New_Standard_Entity ("standard_address"); Build_Unsigned_Integer_Type (Standard_Address, System_Address_Size); + Set_Is_Descendant_Of_Address (Standard_Address); -- Note: universal integer and universal real are constructed as fully -- formed signed numeric types, with parameters corresponding to the diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 1a1eace600b..5d3413c1505 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -7284,10 +7284,20 @@ package body Freeze is elsif Is_Integer_Type (E) then Adjust_Esize_For_Alignment (E); - if Is_Modular_Integer_Type (E) - and then Warn_On_Suspicious_Modulus_Value - then - Check_Suspicious_Modulus (E); + if Is_Modular_Integer_Type (E) then + -- Standard_Address has been built with the assumption that its + -- modulus was System_Address_Size, but this is not a universal + -- property and may need to be corrected. + + if Is_RTE (E, RE_Address) then + Set_Modulus (Standard_Address, Modulus (E)); + Set_Intval + (High_Bound (Scalar_Range (Standard_Address)), + Modulus (E) - 1); + + elsif Warn_On_Suspicious_Modulus_Value then + Check_Suspicious_Modulus (E); + end if; end if; -- The pool applies to named and anonymous access types, but not