From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2066) id 803943851C24; Sat, 13 Jun 2020 02:59:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 803943851C24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592017185; bh=O/raCUFeqjqBag+7mFzuUHZb37tL1YkUp+sG6HyZkbQ=; h=From:To:Subject:Date:From; b=J0H18NKI53r1MOJ8MR8wWUDAp/NlcM15ZWeqI07NKfShiNBF5aJoik5RbJ49ZNvdu 64kqwqbupjYVUhzsdFUUPxbytBmi45T0DIbCrdNPAwcYXyYaadsjwpiYobLuTa51b0 +Iosuzd3NIAcMAHar1DHTkB8BKWahLweTH/4XTZg= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jiu Fu Guo To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/guojiufu/heads/personal-branch)] [Ada] Simplify getting discriminant value from a list of constraints X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/users/guojiufu/heads/personal-branch X-Git-Oldrev: ec772e4b269206a943b3caa5544d9c7ac1d8de1a X-Git-Newrev: 51ebdbc91a8bbbd7509273075f3953b335b8c7c1 Message-Id: <20200613025945.803943851C24@sourceware.org> Date: Sat, 13 Jun 2020 02:59:45 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jun 2020 02:59:45 -0000 https://gcc.gnu.org/g:51ebdbc91a8bbbd7509273075f3953b335b8c7c1 commit 51ebdbc91a8bbbd7509273075f3953b335b8c7c1 Author: Piotr Trojanek Date: Fri Mar 13 21:32:25 2020 +0100 [Ada] Simplify getting discriminant value from a list of constraints 2020-06-12 Piotr Trojanek gcc/ada/ * sem_ch3.adb (Get_Discr_Value): Cleanup. Diff: --- gcc/ada/sem_ch3.adb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index ff1f6dbd651..2e9a3d0758c 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -13112,8 +13112,8 @@ package body Sem_Ch3 is function Is_Discriminant (Expr : Node_Id) return Boolean; -- Returns True if Expr is a discriminant - function Get_Discr_Value (Discrim : Entity_Id) return Node_Id; - -- Find the value of discriminant Discrim in Constraint + function Get_Discr_Value (Discr_Expr : Node_Id) return Node_Id; + -- Find the value of a discriminant named by Discr_Expr in Constraints ----------------------------------- -- Build_Constrained_Access_Type -- @@ -13335,7 +13335,11 @@ package body Sem_Ch3 is -- Get_Discr_Value -- --------------------- - function Get_Discr_Value (Discrim : Entity_Id) return Node_Id is + function Get_Discr_Value (Discr_Expr : Node_Id) return Node_Id is + Discr_Id : constant Entity_Id := Entity (Discr_Expr); + -- Entity of a discriminant that appear as a standalone expression in + -- the constraint of a component. + D : Entity_Id; E : Elmt_Id; @@ -13351,9 +13355,9 @@ package body Sem_Ch3 is E := First_Elmt (Constraints); while Present (D) loop - if D = Entity (Discrim) - or else D = CR_Discriminant (Entity (Discrim)) - or else Corresponding_Discriminant (D) = Entity (Discrim) + if D = Discr_Id + or else D = CR_Discriminant (Discr_Id) + or else Corresponding_Discriminant (D) = Discr_Id then return Node (E); end if; @@ -13373,12 +13377,12 @@ package body Sem_Ch3 is -- be present when the component is a discriminated task type? if Is_Derived_Type (Typ) - and then Scope (Entity (Discrim)) = Etype (Typ) + and then Scope (Discr_Id) = Etype (Typ) then D := First_Discriminant (Etype (Typ)); E := First_Elmt (Constraints); while Present (D) loop - if D = Entity (Discrim) then + if D = Discr_Id then return Node (E); end if;