From patchwork Tue Jun 15 10:20:51 2021 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: 1492095 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 4G449J6bzJz9sTD for ; Tue, 15 Jun 2021 20:21:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 34378398B438 for ; Tue, 15 Jun 2021 10:21:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id 1DCDA3892466 for ; Tue, 15 Jun 2021 10:20:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1DCDA3892466 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id EE310117B0D; Tue, 15 Jun 2021 06:20:51 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 6upuQxayBzmz; Tue, 15 Jun 2021 06:20:51 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id D96D9117AD0; Tue, 15 Jun 2021 06:20:51 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id D866E1CA; Tue, 15 Jun 2021 06:20:51 -0400 (EDT) Date: Tue, 15 Jun 2021 06:20:51 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Subject: [Ada] Add more initialization of Stored_Constraint Message-ID: <20210615102051.GA2461@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: Richard Kenner Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" There several more missing cases of needing to reinitialize Stored_Contraint when changing Etype from an incomplete type to a modular or array type (where the field is Original_Array_Type). Also, include the node number in the -gnatd_v output. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Array_Type_Declaration, Build_Derived_Type): Reinitialize Stored_Constraint when needed. (Set_Modular_Size): Likewise. * atree.adb: (Check_Vanishing_Fields): Add node id to debugging information. diff --git a/gcc/ada/atree.adb b/gcc/ada/atree.adb --- a/gcc/ada/atree.adb +++ b/gcc/ada/atree.adb @@ -772,7 +772,8 @@ package body Atree is Write_Str (New_Kind'Img); Write_Str (" Nonzero field "); Write_Str (F'Img); - Write_Str (" is vanishing"); + Write_Str (" is vanishing for node "); + Write_Int (Nat (Old_N)); Write_Eol; raise Program_Error; @@ -845,7 +846,8 @@ package body Atree is Write_Str (New_Kind'Img); Write_Str (" Nonzero field "); Write_Str (F'Img); - Write_Str (" is vanishing "); + Write_Str (" is vanishing for node "); + Write_Int (Nat (Old_N)); Write_Eol; if New_Kind = E_Void or else Old_Kind = E_Void then diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -6191,6 +6191,12 @@ package body Sem_Ch3 is if Nkind (Def) = N_Constrained_Array_Definition then + if Ekind (T) in Incomplete_Or_Private_Kind then + Reinit_Field_To_Zero (T, Stored_Constraint); + else + pragma Assert (Ekind (T) = E_Void); + end if; + -- Establish Implicit_Base as unconstrained base type Implicit_Base := Create_Itype (E_Array_Type, P, Related_Id, 'B'); @@ -9749,6 +9755,12 @@ package body Sem_Ch3 is begin -- Set common attributes + if Ekind (Derived_Type) in Incomplete_Or_Private_Kind + and then Ekind (Parent_Base) in Modular_Integer_Kind | Array_Kind + then + Reinit_Field_To_Zero (Derived_Type, Stored_Constraint); + end if; + Set_Scope (Derived_Type, Current_Scope); Set_Etype (Derived_Type, Parent_Base); Mutate_Ekind (Derived_Type, Ekind (Parent_Base)); @@ -19618,6 +19630,11 @@ package body Sem_Ch3 is -- Proceed with analysis of mod expression Analyze_And_Resolve (Mod_Expr, Any_Integer); + + if Ekind (T) in Incomplete_Or_Private_Kind then + Reinit_Field_To_Zero (T, Stored_Constraint); + end if; + Set_Etype (T, T); Mutate_Ekind (T, E_Modular_Integer_Type); Init_Alignment (T);