aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2022-08-23 17:16:44 +0200
committerMarc Poulhiès <poulhies@adacore.com>2022-11-04 14:47:29 +0100
commitcb3c260460073bed267fae3ee970947a24858211 (patch)
tree1bd059e4a3726187bbb9c3d18cf9aca421dcadd1
parent265341dc527754b8b3d390e870b43f00142933f7 (diff)
downloadgcc-cb3c260460073bed267fae3ee970947a24858211.zip
gcc-cb3c260460073bed267fae3ee970947a24858211.tar.gz
gcc-cb3c260460073bed267fae3ee970947a24858211.tar.bz2
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.
-rw-r--r--gcc/ada/sem_ch7.adb21
1 files changed, 9 insertions, 12 deletions
diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb
index 5c347bd..77d1b38 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.