From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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-x42d.google.com with SMTP id n3so2534823wrp.5 for ; Mon, 21 Nov 2022 02:14:53 -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=EQQv6PJfanMNLaALoqZDE/lxubjdnkZ/zLJ72blllu0=; b=QGQdZvk5mhZ54cyg7l/AU4yo86gmRxyG1p0L+OhhcHzqp48WAE19CxolqmW5W1b3pb O5F/b0i+6hOOuLjnzs3HHGcPhRpPmS2hbUt0AqhV7NbY9q7QOnSTz3SZHzgu+4jJSiV+ kBCsmMuIlYiYVcRN9RzzmNFB+JMRCFltlnEmZgJFa1zW05ckH+ara4urrOca3gf9KQrM jdy0pTESRQu3IK7NSAzKLIXK97APVBJned2Xk/SAhkAS4NsyytsyiazZIdLJT8IcMuBg nfLlTJIuCwiWuKL4wMOfPXmfKUdf6sD0j/Lf5/Y0l9XSi1DS3QBdboJMXkce3uzVwK8L 5mLg== 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-Google-Smtp-Source: AA0mqf49Snaq11o0JeruVQRLz7OfkK0X0NYzpD7Uqxj106vK5v2C5Kk+y1jw9h4Jqzuc1i6qvX/LWA== 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) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: =?UTF-8?q?Marc=20Poulhi=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 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: 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; -- 2.34.1