From patchwork Fri Jan 7 16:27:22 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: 49716 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 B411E3857C67 for ; Fri, 7 Jan 2022 16:50:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B411E3857C67 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641574238; bh=rxFdqaIILX9dOw4qmjIMOHjyz/HaW+lfIaeiaUBZqWw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ICTRIXbUP2B7mDjtwpnyIfwRLdAkksp7bruwl9rsxysQewaQy3r5kblOhJRnlzoBP VIFZ1ZG++8hDg/NP+Lp9h1gfwPiFKNjk/sLdEcP5jmgXbSXS51EUsrenldYNewBv6u i+gzFmVpOX4WtEmaEmuqAeIrvhMb459XaEo4n0aQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 124593857C7C for ; Fri, 7 Jan 2022 16:27:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 124593857C7C Received: by mail-wr1-x42b.google.com with SMTP id l10so12044185wrh.7 for ; Fri, 07 Jan 2022 08:27:24 -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=rxFdqaIILX9dOw4qmjIMOHjyz/HaW+lfIaeiaUBZqWw=; b=x4Rgaq+MYFtAewkAiglfxZZeARbcCiC+v3K2qaO0WEGbeoWayOgZlsdM/hV7r+cpXq 1Bn+ExU4SKfC3duYYF/nJC/fuS2gOrC3O5tLHhTMwI9yEogBdBscC2ARvYnZxvzMtdPE 2pd3N6fbXbF5y/gBpQXLtNeXqjvxcqb5jPwgdnolFKqm54Q5vqjd0MZn2+8drIXSABYl ZEc1/LxpUPSHtZ5m6z3QDOTf1Y+kPnI6gvHdHmmSGNqz6wQcjMhX6fxxN5fqZcYqiYHy g8MzG2ACv2hCifofi3pRxj8v+/QYwUcd5VHvFqqpOsP1cuKmt+qgICIliW1b1k/l0RdB 7O/g== X-Gm-Message-State: AOAM533G2oXCBLESlAZIqCqUJEH/480RlMtWo5cQHUtqz/p1kBwftORL usv0HGDCsAWM8ayIKDKKaP8vcAqwsubgOA== X-Google-Smtp-Source: ABdhPJxqc7xUmT5oHVdrzA9O0RnucFo4hvAMbPFprrz6o1LgKR37WXoBXcMjf9hdTpEuApQI8V6I5A== X-Received: by 2002:a05:6000:23a:: with SMTP id l26mr53377852wrz.666.1641572843114; Fri, 07 Jan 2022 08:27:23 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id j11sm1269458wrt.5.2022.01.07.08.27.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 08:27:22 -0800 (PST) Date: Fri, 7 Jan 2022 16:27:22 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] More default initialization for multi-dim array aggregates Message-ID: <20220107162722.GA948763@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: Piotr Trojanek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Expansion of multi-dimensional array aggregates with boxes (e.g. "(others => (others => <>))" only applied default initialization to components of a scalar type with Default_Value aspect and of an access type (which are initialized by default to null). Now default initialization is applied to components of all types that require default initialization (e.g. because of pragma Normalize_Scalars), except for those with pragma Suppress_Initialization. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Gen_Assign): Remove explicit initialization for components of access types. (Get_Assoc_Expr): Enable initialization for components of all types that require simple initialization. diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -1872,12 +1872,6 @@ package body Exp_Aggr is Set_Etype (Indexed_Comp, Ctype); Append_To (Stmts, Make_Invariant_Call (Indexed_Comp)); end if; - - elsif Is_Access_Type (Ctype) then - Append_To (Stmts, - Make_Assignment_Statement (Loc, - Name => New_Copy_Tree (Indexed_Comp), - Expression => Make_Null (Loc))); end if; if Needs_Finalization (Ctype) then @@ -2212,15 +2206,10 @@ package body Exp_Aggr is begin if Box_Present (Assoc) then - if Is_Scalar_Type (Ctype) then - if Present (Default_Aspect_Component_Value (Typ)) then - return Default_Aspect_Component_Value (Typ); - elsif Present (Default_Aspect_Value (Ctype)) then - return Default_Aspect_Value (Ctype); - else - return Empty; - end if; - + if Present (Default_Aspect_Component_Value (Typ)) then + return Default_Aspect_Component_Value (Typ); + elsif Needs_Simple_Initialization (Ctype) then + return Get_Simple_Init_Val (Ctype, N); else return Empty; end if;