From patchwork Mon Oct 25 15:09:34 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: 46637 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 0DF3B3858C27 for ; Mon, 25 Oct 2021 15:29:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DF3B3858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635175744; bh=WVsc2cLWmOdtTv6/WhCe/SoOjx7P5oh3kB/gNAHiE/k=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=BD8Dn0NQyrhMlDxzzaedYLfPkg18m7a0XpUwXJv5RnWDdTgFSRsmOeEi3WdRQNVA2 Pgtm35EagbHDj+EvL4eGsSoZdcrEvw+H2BxQ1ZC87hZ6GzcEnpqgsZhDmqqMDjdR6x zmoZH9uxFf2glK5rHL0isZYZu5LfiWGTPj8+qBTs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 9F06A3858001 for ; Mon, 25 Oct 2021 15:09:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9F06A3858001 Received: by mail-lj1-x232.google.com with SMTP id u5so12838192ljo.8 for ; Mon, 25 Oct 2021 08:09:37 -0700 (PDT) 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=WVsc2cLWmOdtTv6/WhCe/SoOjx7P5oh3kB/gNAHiE/k=; b=vQDWSM+M4IJF6JoOWcRc6Ndl7HWd+ymORWrBjuMe8ImYzbL5oBVaKEE4G2rli4bO2j eL70dQjR3lG3r3Z8jA1GHSahk2M5E03ZA6dT6uJd4r9LcGjoESmpmuJ9acaPmubfSDV4 h/1+/l7NI2mozfvEyLK9HPGyWojFuOKjrRuNsPlfB+xIh9y7ILOnkSlZK6P9igyTE7h6 4bQK9sUEaUL/foxvRavmu/bHgGSnR2k37AqIARXCGLmi+ugM9s/IxSqbdtRF01cU4sI7 C+E+Ht6QsRH+QN9zRB4mbrbR7yt+6OmobIsPVg4akdaUTlrhsGiOpkcGd21myg554UcB Ljhw== X-Gm-Message-State: AOAM5304qFp22ZQQuAAhqYQMGHP5xc9ZziI709Z/ztU96FrD2h/EegvE HRSgwIeRdTqPajxHEiWp7nkP+DCv8Yx9jlpK X-Google-Smtp-Source: ABdhPJx20v6EHEPEBVlXS8yT2orBDwhHzWJQRVLszzUdZLTvUfkMvz7eOC3IVobdZdmU0YrYIKdG+w== X-Received: by 2002:a2e:b8c3:: with SMTP id s3mr19188790ljp.44.1635174576528; Mon, 25 Oct 2021 08:09:36 -0700 (PDT) Received: from adacore.com ([2a02:2ab8:224:2ce:72b5:e8ff:feef:ee60]) by smtp.gmail.com with ESMTPSA id g18sm1150207lfv.25.2021.10.25.08.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 08:09:35 -0700 (PDT) Date: Mon, 25 Oct 2021 15:09:34 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Follow-on cleanups for Uint fields Message-ID: <20211025150934.GA346822@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.0 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: Bob Duff Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Subsequent to prior major cleanups of Uint fields, this patch includes a few more, fairly minor, cleanups. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Freeze_Fixed_Point_Type): Remove previously-inserted test for Uint_0; no longer needed. * gen_il-gen.ads: Improve comments. * repinfo.adb (Rep_Value): Use Ubool type for B. * repinfo.ads (Node_Ref): Use Unegative type. (Node_Ref_Or_Val): Document that values of this type can be No_Uint. * exp_disp.adb (Make_Disp_Requeue_Body): Minor comment fix. * sem_ch3.adb: Likewise. * sem_ch8.adb: Likewise. * sinfo-utils.adb (End_Location): End_Span can never be No_Uint, so remove the "if No (L)" test. * uintp.adb (Image_String): Use "for ... of" loop. * uintp.ads (Unegative): New type for negative integers. We give it a long name (unlike Unat and Upos) because it is rarely used. diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -3037,7 +3037,7 @@ package body Exp_Disp is begin pragma Assert (not Restriction_Active (No_Dispatching_Calls)); - -- Null body is generated for interface types and non-concurrent + -- Null body is generated for interface types and nonconcurrent -- tagged types. if Is_Interface (Typ) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -9500,9 +9500,7 @@ package body Freeze is Minsiz : constant Uint := UI_From_Int (Minimum_Size (Typ)); begin - if Known_RM_Size (Typ) - and then RM_Size (Typ) /= Uint_0 - then + if Known_RM_Size (Typ) then if RM_Size (Typ) < Minsiz then Error_Msg_Uint_1 := RM_Size (Typ); Error_Msg_Uint_2 := Minsiz; diff --git a/gcc/ada/gen_il-gen.ads b/gcc/ada/gen_il-gen.ads --- a/gcc/ada/gen_il-gen.ads +++ b/gcc/ada/gen_il-gen.ads @@ -204,9 +204,22 @@ package Gen_IL.Gen is -- Gen_IL.Fields, and delete all occurrences from Gen_IL.Gen.Gen_Entities. -- If a field is not set, it is initialized by default to whatever value is - -- represented by all-zero bits, with two exceptions: Elist fields default - -- to No_Elist, and Uint fields default to Uint_0. In retrospect, it would - -- have been better to use No_Uint instead of Uint_0. + -- represented by all-zero bits, with some exceptions. This means Flags are + -- initialized to False, Node_Ids and List_Ids are initialized to Empty, + -- and enumeration fields are initialized to 'First of the type (assuming + -- there is no representation clause). + -- + -- Elists default to No_Elist. + -- + -- Fields of type Uint (but not its subtypes) are initialized to No_Uint. + -- Fields of subtypes Valid_Uint, Unat, Upos, Nonzero_Uint, and Ureal have + -- no default; it is an error to call a getter before calling the setter. + -- Likewise, other types whose range does not include zero have no default + -- (see package Types for the ranges). + -- + -- If a node is created by a function in Nmake, then the defaults are + -- different from what is specified above. The parameters of Make_... + -- functions can have defaults specified; see Create_Syntactic_Field. procedure Create_Node_Union_Type (T : Abstract_Node; Children : Type_Array); diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -2120,7 +2120,7 @@ package body Repinfo is function Rep_Value (Val : Node_Ref_Or_Val; D : Discrim_List) return Uint is - function B (Val : Boolean) return Uint; + function B (Val : Boolean) return Ubool; -- Returns Uint_0 for False, Uint_1 for True function T (Val : Node_Ref_Or_Val) return Boolean; @@ -2141,7 +2141,7 @@ package body Repinfo is -- B -- ------- - function B (Val : Boolean) return Uint is + function B (Val : Boolean) return Ubool is begin if Val then return Uint_1; diff --git a/gcc/ada/repinfo.ads b/gcc/ada/repinfo.ads --- a/gcc/ada/repinfo.ads +++ b/gcc/ada/repinfo.ads @@ -118,12 +118,12 @@ package Repinfo is -- this field is done only in -gnatR3 mode, and in other modes, the value -- is set to Uint_Minus_1. - subtype Node_Ref is Uint; + subtype Node_Ref is Unegative; -- Subtype used for negative Uint values used to represent nodes subtype Node_Ref_Or_Val is Uint; - -- Subtype used for values that can either be a Node_Ref (negative) - -- or a value (non-negative) + -- Subtype used for values that can be a Node_Ref (negative) or a value + -- (non-negative) or No_Uint. type TCode is range 0 .. 27; -- Type used on Ada side to represent DEFTREECODE values defined in @@ -306,7 +306,7 @@ package Repinfo is -- In the case of components, if the location of the component is static, -- then all four fields (Component_Bit_Offset, Normalized_Position, Esize, -- and Normalized_First_Bit) are set to appropriate values. In the case of - -- a non-static component location, Component_Bit_Offset is not used and + -- a nonstatic component location, Component_Bit_Offset is not used and -- is left set to Unknown. Normalized_Position and Normalized_First_Bit -- are set appropriately. 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 @@ -21301,7 +21301,7 @@ package body Sem_Ch3 is goto Leave; end; - -- For non-concurrent types, transfer explicit primitives, but + -- For nonconcurrent types, transfer explicit primitives, but -- omit those inherited from the parent of the private view -- since they will be re-inherited later on. diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -9236,7 +9236,7 @@ package body Sem_Ch8 is if Ekind (S) = E_Void then null; - -- Set scope depth if not a non-concurrent type, and we have not yet set + -- Set scope depth if not a nonconcurrent type, and we have not yet set -- the scope depth. This means that we have the first occurrence of the -- scope, and this is where the depth is set. diff --git a/gcc/ada/sinfo-utils.adb b/gcc/ada/sinfo-utils.adb --- a/gcc/ada/sinfo-utils.adb +++ b/gcc/ada/sinfo-utils.adb @@ -189,13 +189,9 @@ package body Sinfo.Utils is ------------------ function End_Location (N : Node_Id) return Source_Ptr is - L : constant Uint := End_Span (N); + L : constant Valid_Uint := End_Span (N); begin - if No (L) then - return No_Location; - else - return Source_Ptr (Int (Sloc (N)) + UI_To_Int (L)); - end if; + return Source_Ptr (Int (Sloc (N)) + UI_To_Int (L)); end End_Location; -------------------- diff --git a/gcc/ada/uintp.adb b/gcc/ada/uintp.adb --- a/gcc/ada/uintp.adb +++ b/gcc/ada/uintp.adb @@ -380,8 +380,8 @@ package body Uintp is procedure Image_String (S : String) is begin - for X in S'Range loop - Image_Char (S (X)); + for X of S loop + Image_Char (X); end loop; end Image_String; diff --git a/gcc/ada/uintp.ads b/gcc/ada/uintp.ads --- a/gcc/ada/uintp.ads +++ b/gcc/ada/uintp.ads @@ -104,6 +104,7 @@ package Uintp is subtype Unat is Valid_Uint with Predicate => Unat >= Uint_0; -- natural subtype Upos is Valid_Uint with Predicate => Upos >= Uint_1; -- positive subtype Nonzero_Uint is Valid_Uint with Predicate => Nonzero_Uint /= Uint_0; + subtype Unegative is Valid_Uint with Predicate => Unegative < Uint_0; subtype Ubool is Valid_Uint with Predicate => Ubool in Uint_0 | Uint_1; subtype Opt_Ubool is Uint with Predicate => No (Opt_Ubool) or else Opt_Ubool in Ubool;