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: 60911 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 BFB383832369 for ; Mon, 21 Nov 2022 10:16:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFB383832369 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669025766; 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=V9eR57hSEXzHDFHqztr3ZWiJFHZk6chsmWuBY345qc0oSiZ/44KDBHcw+sezujsDb MnH8ZTEUIj+MLNiBbRUt0g4Zog+8TiIbGnWqpoXIEwdAknrq9cI8OqwiJBLI/Ot6pg XR9el15K8w8SwwSUGxcMcGiXiWdBZF4HjVVk42Ag= 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-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) 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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;