From patchwork Mon Jan 10 09:41:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1577833 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=HZjQfr/G; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JXTQP1NPJz9s9c for ; Mon, 10 Jan 2022 20:42:53 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 99A433891C1D for ; Mon, 10 Jan 2022 09:42:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99A433891C1D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641807770; bh=OPimj3+L+mPk7sqGBZ9laRBf2QATB77IkQTxbdhbe1A=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=HZjQfr/GNcQZmeRD/AXbnIXKseHUt8iSHzdH1YxeOyUZ4k+L2B45CX0yCFy+dfQuD 0/sXhrAAmk0Y0/x3NkfwdiPgWkEnNsLVpudXjEPvKRYZoBtTzepA2TyVF+rjWxnruZ BLX43b3MLZoWzKwoxhvHWqnsUJyJ4WBRxyTaph8Y= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 4F6323858406 for ; Mon, 10 Jan 2022 09:41:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4F6323858406 Received: by mail-wr1-x433.google.com with SMTP id o3so25530767wrh.10 for ; Mon, 10 Jan 2022 01:41:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=OPimj3+L+mPk7sqGBZ9laRBf2QATB77IkQTxbdhbe1A=; b=WUIwQojvHQ1o4+hAObNPEnf9RagHamOYrRLMObsfmb/1TQGTlff0RMBTNf+Cz1+mbe BYKhDfszEgXtsfoZtFnXiSnZnj1awuTL8FnFMKvyFXr1BSEQjohmisixxUVYwuTEfTmn vOQT0I0QSND4HuS+18qZ01uqptkwbHi/frxbXjrUQP1+NzlXw8hFwOorP3oWdbcFhPXy pQFVFy9TbfqBwo80G3yhYOc2KGNmJUKLzrTA8DNsH1RlXGWXLKiWjEZILA0UIFAyNgTy MQA4d7vdrisZQPaXcR9y/bU+8fujYrBxhGCMHE4LkXSodH/JOKbj4PPcymdy6v+nOQyy 4seQ== X-Gm-Message-State: AOAM531CZgxGzMj14vyustPX4Sr3H19R8Ww9x/ASUMcRrTctSftdYcoQ F93RJcXHhGvugn/sb5LUBOuF+BTtfvQ6GA== X-Google-Smtp-Source: ABdhPJxXsFFy/JyVlyn/4K7jcY8n4fTXcLe9PYQ1RLQYE/iGbgNhxHrXP1Vp15so3RmtgBV8IAXWYA== X-Received: by 2002:a05:6000:1d84:: with SMTP id bk4mr7678300wrb.708.1641807693342; Mon, 10 Jan 2022 01:41:33 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id r11sm6773863wrz.78.2022.01.10.01.41.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jan 2022 01:41:32 -0800 (PST) Date: Mon, 10 Jan 2022 09:41:32 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix error on too large size clause for bit-packed array Message-ID: <20220110094132.GA586014@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.1 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Eric Botcazou Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The compiler should give again a warning instead of an error, which comes from an improper Esize set on the bit-packed array type by Layout_Type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_pakd.adb (Install_PAT): Do not reset the alignment here. * layout.adb (Layout_Type): Call Adjust_Esize_Alignment after having copied the RM_Size onto the Esize when the latter is too small. diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb --- a/gcc/ada/exp_pakd.adb +++ b/gcc/ada/exp_pakd.adb @@ -577,7 +577,6 @@ package body Exp_Pakd is -- Set remaining fields of packed array type - Reinit_Alignment (PAT); Set_Parent (PAT, Empty); Set_Associated_Node_For_Itype (PAT, Typ); Set_Original_Array_Type (PAT, Typ); diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb --- a/gcc/ada/layout.adb +++ b/gcc/ada/layout.adb @@ -616,7 +616,7 @@ package body Layout is Size : constant Uint := RM_Size (E); begin - Set_Esize (E, RM_Size (E)); + Set_Esize (E, Size); -- For scalar types, increase Object_Size to power of 2, but -- not less than a storage unit in any case (i.e., normally @@ -641,6 +641,11 @@ package body Layout is loop Set_Alignment (E, 2 * Alignment (E)); end loop; + + -- For the other types, apply standard adjustments + + else + Adjust_Esize_Alignment (E); end if; end; end if;