From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 883843857431; Fri, 4 Nov 2022 13:54:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 883843857431 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667570093; bh=Qo7m6iM7pCKGVAzWLm45RBP0pQoE8WuHrQotHjEd7bk=; h=From:To:Subject:Date:From; b=VvIF8lrSs4XcJPqaQlNdcdk6/nadLcQUpWT6t9oZ2rNqko0ZXLqAxoneh2djTeHZn LWS17q+RPuowDW1K3pSNoFKpqxb4C4mfEsgZ4jFUZZUSu7OgiWyHmTzzlq0jFoDt6B IZZUS0yePoSZtBt0gNQqLKr9N87+V3g34N3avkZc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3673] ada: Cleanup clearing flags on package variables X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: 265341dc527754b8b3d390e870b43f00142933f7 X-Git-Newrev: cb3c260460073bed267fae3ee970947a24858211 Message-Id: <20221104135453.883843857431@sourceware.org> Date: Fri, 4 Nov 2022 13:54:53 +0000 (GMT) List-Id: https://gcc.gnu.org/g:cb3c260460073bed267fae3ee970947a24858211 commit r13-3673-gcb3c260460073bed267fae3ee970947a24858211 Author: Piotr Trojanek Date: Tue Aug 23 17:16:44 2022 +0200 ada: Cleanup clearing flags on package variables When killing flags on assignable entities we iterated from First_Entity and then again from First_Private_Entity. This second iteration was unnecessary, because the entity chain that starts with First_Entity contains all entities, including the private ones. This is just a performance improvement; the behavior is unchanged. gcc/ada/ * sem_ch7.adb (Clear_Constants): Only iterate from First_Entity through Next_Entity; only examine variables because packages have no assignable formal parameters. Diff: --- gcc/ada/sem_ch7.adb | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb index 5c347bd8b4f..77d1b38b827 100644 --- a/gcc/ada/sem_ch7.adb +++ b/gcc/ada/sem_ch7.adb @@ -1317,11 +1317,10 @@ package body Sem_Ch7 is -- private_with_clauses, and remove them at the end of the nested -- package. - procedure Clear_Constants (Id : Entity_Id; FE : Entity_Id); - -- Clears constant indications (Never_Set_In_Source, Constant_Value, and - -- Is_True_Constant) on all variables that are entities of Id, and on - -- the chain whose first element is FE. A recursive call is made for all - -- packages and generic packages. + procedure Clear_Constants (Id : Entity_Id); + -- Clears constant indications (Never_Set_In_Source, Constant_Value, + -- and Is_True_Constant) on all variables that are entities of Id. + -- A recursive call is made for all packages and generic packages. procedure Generate_Parent_References; -- For a child unit, generate references to parent units, for @@ -1352,7 +1351,7 @@ package body Sem_Ch7 is -- Clear_Constants -- --------------------- - procedure Clear_Constants (Id : Entity_Id; FE : Entity_Id) is + procedure Clear_Constants (Id : Entity_Id) is E : Entity_Id; begin @@ -1368,9 +1367,9 @@ package body Sem_Ch7 is -- package can contain a renaming declaration to itself, and such -- renamings are generated automatically within package instances. - E := FE; + E := First_Entity (Id); while Present (E) and then E /= Id loop - if Is_Assignable (E) then + if Ekind (E) = E_Variable then Set_Never_Set_In_Source (E, False); Set_Is_True_Constant (E, False); Set_Current_Value (E, Empty); @@ -1382,8 +1381,7 @@ package body Sem_Ch7 is end if; elsif Is_Package_Or_Generic_Package (E) then - Clear_Constants (E, First_Entity (E)); - Clear_Constants (E, First_Private_Entity (E)); + Clear_Constants (E); end if; Next_Entity (E); @@ -2009,8 +2007,7 @@ package body Sem_Ch7 is if Is_Library_Level_Entity (Id) or else Is_Generic_Instance (Id) then - Clear_Constants (Id, First_Entity (Id)); - Clear_Constants (Id, First_Private_Entity (Id)); + Clear_Constants (Id); end if; -- Output relevant information as to why the package requires a body.