From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 7CDED385803D for ; Fri, 4 Nov 2022 13:57:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7CDED385803D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x32c.google.com with SMTP id a11-20020a05600c2d4b00b003cf6f5fd9f1so3238115wmg.2 for ; Fri, 04 Nov 2022 06:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kpJQGcLuB5dZPJ75O7OK51mozXlns14GR+gViU+gTkI=; b=gkakKtkU2gc8SdT1mXepFAvTQinkpYqEROxmC4LelY1dUfEijLHXLUAdu7MnWGLTsh izbge0C/DllFZ3F7NaHb+VslL7eroauehXsKIc35IGtFU22kq0elcujWNIJgmQi/3+bi lobDfduwa42vgcongKh/XWBDguWjiW3sJLPzEh2KuVxowO85+DKaUjPVABY/fpu+XAlC xfAIptFldA9iZ/rqMuuBvwuLQ+voHJKBkV3FH7ur1Dnq+oW+6R+aLSF8PWLcksRJ5DCj EGItR+6+SywcCUe5ZLbO7ursU60fQ0kymOEkVpH5+oQ9DfgV4aVrciyumo1mcU7KoMgY 3hrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kpJQGcLuB5dZPJ75O7OK51mozXlns14GR+gViU+gTkI=; b=mooo1m/RcEkcYt9zVX/HqyT2mYBiPMYvzEMc10HT05wTnm5bc3M0H94w1XRFxXSDSV nk9nrmqn9mGteKK//iyTi1LQUDfhwrWgX7701HKb4PWJoPtnWB/CBa8PvKAT/0W/xZCu IUNf2jCcejjehFa1sUmwxYfa0LWsppla/RWlwSTTQF5oWhGM4Bq04IfcVd/QztJ6U6ny kTE8p+mz2+d81CjuhKyXz6OKZfaYdzmK0eGT2qfjfRJctHhn6uefGlQ7EGX0g8UOcPHF BRjpy5z6yElKQ9w6MwanacK2JZfE2mejsO9di7VnYQF317QXytV/7VmWVXjZuM1JHkWf CcYg== X-Gm-Message-State: ACrzQf2JjkIqcyBKWmcHv23wv0W6swGnTM4SaDCvcFhqjkq11tLNckkZ VWcoQztjD9fkCtW2oUT/7w75v7M834RtXw== X-Google-Smtp-Source: AMsMyM6EOUUi8WlPDlWW1Us5M0xWjHRd/Lork/KjRR3axn0ocSvG3itQ+tn9+K57vJCJ/w9AOMfb+A== X-Received: by 2002:a05:600c:1d2a:b0:3cf:7332:946 with SMTP id l42-20020a05600c1d2a00b003cf73320946mr17997765wms.126.1667570276256; Fri, 04 Nov 2022 06:57:56 -0700 (PDT) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id i2-20020a05600c354200b003c71358a42dsm4131363wmq.18.2022.11.04.06.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:57:55 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Cleanup clearing flags on package variables Date: Fri, 4 Nov 2022 14:57:52 +0100 Message-Id: <20221104135752.86633-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.3 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Piotr Trojanek 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. Tested on x86_64-pc-linux-gnu, committed on master. --- 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. -- 2.34.1