From patchwork Mon Nov 21 10:14:49 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: 23643 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1494315wrr; Mon, 21 Nov 2022 02:18:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf7TDaXPq7rl0lNHA1WeUv74nAhrj9eX1xVVrGp5twThhvdgJbKrKfExgVxvXn7iGuz8QuD4 X-Received: by 2002:a17:906:9493:b0:7ad:83cb:85e6 with SMTP id t19-20020a170906949300b007ad83cb85e6mr15178790ejx.108.1669025897163; Mon, 21 Nov 2022 02:18:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669025897; cv=none; d=google.com; s=arc-20160816; b=QPG5p6t6JIIvP1NMFQuS3kleQ26xY6g1nyI21uBUV19b/oxo/o5uNIMpjPGANrDWNG EJemEckEC1sbUXlpu8CjOWrFOxuEijK8bd+Gl/4R4RpzG1eEBnauJD4YUm6XKdpuFFCN YdVWx4eq9pfRKabNQz/JiNRUxG2kuebclobxgtYuE73ELnYMNMDzAULCTvnH9i1Als2V iZar6mruL4S7Jv9yIbTCqH07O/M/eMW8UCq7T5wyz9R7dpENYJLkkpk0tujlFiEXIHjy RAUxXA2bKSE6/nbpJLEW//h7hQ6uSeK8XKYU4jtf6orRy1PaAK9CTm16P8UVYhYKwWRR 6Klw== 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=EQQv6PJfanMNLaALoqZDE/lxubjdnkZ/zLJ72blllu0=; b=bxGma7zxAgs2JEkOemarSTBplYV0FCHqn5tnua1SH16D2+LrslCgKLZqGEZU9lbRCV H1J1k3Fa59w91Vnvefo9UeRbC0iWy468IbFoNNofHvwMbSLu+kpPHY2FFNL63ugyCDE5 sPsFxxeMk4MJhAmnnSXl+uvAP1yaGPwDZbPc2P2n/OQ/Du9PWnokqJBDQsRqyFBMOGG5 lVd7mgLeGodcxnfH8nkE2DyiFL3nz+dmKRbKnwP8+ZuXritoTkxaJR5ZoFJYLzse8WLp +H49oCpB2DeHUwhBc/EfTG01+uFNHKc8PWCp70ApBFkDpO97Q3rS1aCj1qtzZltDNs7T SCtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=SRZ5g0ip; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id l25-20020a056402345900b0046883aeffd8si1229107edc.278.2022.11.21.02.18.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 02:18:17 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=SRZ5g0ip; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 0D2E73948808 for ; Mon, 21 Nov 2022 10:16:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D2E73948808 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669025783; bh=EQQv6PJfanMNLaALoqZDE/lxubjdnkZ/zLJ72blllu0=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=SRZ5g0ipJFHgenK/RDEHDmaNy1oJfIdkKzsz9JgS2u3O0M63n6SYIrVmzENDEwmjD XarEcv7RGFAOgNENnn1VwCrGm5HLTqpPfFxv87moWFjHDOIafi/NOqMaM2NExLlsiS 1tTU4NCUB17+rGKpoQ0ejGzfr+BbsIO/ihLoE9B8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 59FE8384F6FD for ; Mon, 21 Nov 2022 10:14:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 59FE8384F6FD Received: by mail-wr1-x42d.google.com with SMTP id n3so2534823wrp.5 for ; Mon, 21 Nov 2022 02:14:53 -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=EQQv6PJfanMNLaALoqZDE/lxubjdnkZ/zLJ72blllu0=; b=YvX7GM7C/RdxiajP/gcqi9PF9z6n9+sip7in8JyK/ZlEfBLLE93d6Jtdix0FKJDBkQ cGkceJLrMeEZKDl3bSt79h39qTLjY1rkBDcGrpKuxV8EzprqePLSX2PsUF7g9MXN4tiV XccdXu/Lf+w/60m0P+kzijqF5RoPHcfEIf+/qU7Z3huxTx9Na44a0B4y+2er4Nq1NQ2M iny0k5JWAqCGTtQwknbUMV4ytIGAD56tTjQd4i2Qun1ZjYRgx6iG7UEMRUNCgyCE21zC ztsrLo4Fq8SaqX+8UHO2k2RS2Tr964oIa3xDJQcXR8gzA3B1Ed6LBZpEV5FoyfO5o5ba 8o9g== X-Gm-Message-State: ANoB5pkuW6y3tJkMC5Thrq8iQsOjvXHErkE8sF/KoCiber4lJNhwx5p4 /NMagy3aN4HhsdBpIt3OjaGSzZqrqhnwZg== X-Received: by 2002:a5d:54d2:0:b0:236:86f2:b3fa with SMTP id x18-20020a5d54d2000000b0023686f2b3famr10643457wrv.457.1669025692169; Mon, 21 Nov 2022 02:14:52 -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 hg12-20020a05600c538c00b003cf7055c014sm13470716wmb.1.2022.11.21.02.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 02:14:51 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: =?utf-8?q?Marc_Poulhi=C3=A8s?= Subject: [COMMITTED] ada: Do not share Packed Array Type if sizes of types differ Date: Mon, 21 Nov 2022 11:14:49 +0100 Message-Id: <20221121101449.259662-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?1750100499158800230?= X-GMAIL-MSGID: =?utf-8?q?1750100499158800230?= If a subtype has a Size attribute value different than the size of its ancestor, then the Packed Array Type can't be shared and a new one must be created. gcc/ada/ * exp_pakd.adb (Create_Packed_Array_Impl_Type): Do not share PAT if sizes of types differ. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_pakd.adb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb index d4a62ace9c2..29735c07a88 100644 --- a/gcc/ada/exp_pakd.adb +++ b/gcc/ada/exp_pakd.adb @@ -671,11 +671,11 @@ package body Exp_Pakd is return; end if; - -- If our immediate ancestor subtype is constrained, and it already - -- has a packed array type, then just share the same type, since the - -- bounds must be the same. If the ancestor is not an array type but - -- a private type, as can happen with multiple instantiations, create - -- a new packed type, to avoid privacy issues. + -- If our immediate ancestor subtype is constrained, and it already has + -- a packed array type, and it has the same size, then just share the + -- same type, since the bounds must be the same. If the ancestor is not + -- an array type but a private type, as can happen with multiple + -- instantiations, create a new packed type, to avoid privacy issues. if Ekind (Typ) = E_Array_Subtype then Ancest := Ancestor_Subtype (Typ); @@ -684,6 +684,9 @@ package body Exp_Pakd is and then Is_Array_Type (Ancest) and then Is_Constrained (Ancest) and then Present (Packed_Array_Impl_Type (Ancest)) + and then Known_Esize (Typ) + and then Known_Esize (Ancest) + and then Esize (Typ) = Esize (Ancest) then Set_Packed_Array_Impl_Type (Typ, Packed_Array_Impl_Type (Ancest)); return;