aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2020-08-11 22:08:10 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-22 08:11:22 -0400
commit903275965921f6f63519f07b4f82467ee39160a1 (patch)
tree4a05260fb5a9e052d00a1535604e7ec3832042d4 /gcc/ada
parent61d832dee4e62fce2376138f8ab3a05c069237b0 (diff)
downloadgcc-903275965921f6f63519f07b4f82467ee39160a1.zip
gcc-903275965921f6f63519f07b4f82467ee39160a1.tar.gz
gcc-903275965921f6f63519f07b4f82467ee39160a1.tar.bz2
[Ada] Reduce scope of local variables for detecting extra WITH clauses
gcc/ada/ * sem_warn.adb (Check_Unused_Withs): Move local variables from to a nested procedure; Lunit is passed as a parameter to Check_System_Aux and its type is refined from Node_Id to Entity_Id; Cnode is now a constant.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/sem_warn.adb22
1 files changed, 12 insertions, 10 deletions
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index aeea318..d1acf2f 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -2254,10 +2254,6 @@ package body Sem_Warn is
------------------------
procedure Check_Unused_Withs (Spec_Unit : Unit_Number_Type := No_Unit) is
- Cnode : Node_Id;
- Item : Node_Id;
- Lunit : Node_Id;
- Ent : Entity_Id;
Munite : constant Entity_Id := Cunit_Entity (Main_Unit);
-- This is needed for checking the special renaming case
@@ -2270,8 +2266,9 @@ package body Sem_Warn is
--------------------
procedure Check_One_Unit (Unit : Unit_Number_Type) is
+ Cnode : constant Node_Id := Cunit (Unit);
+
Is_Visible_Renaming : Boolean := False;
- Pack : Entity_Id;
procedure Check_Inner_Package (Pack : Entity_Id);
-- Pack is a package local to a unit in a with_clause. Both the unit
@@ -2279,7 +2276,7 @@ package body Sem_Warn is
-- referenced, then the only occurrence of Pack is in a USE clause
-- or a pragma, and a warning is worthwhile as well.
- function Check_System_Aux return Boolean;
+ function Check_System_Aux (Lunit : Entity_Id) return Boolean;
-- Before giving a warning on a with_clause for System, check whether
-- a system extension is present.
@@ -2358,7 +2355,7 @@ package body Sem_Warn is
-- Check_System_Aux --
----------------------
- function Check_System_Aux return Boolean is
+ function Check_System_Aux (Lunit : Entity_Id) return Boolean is
Ent : Entity_Id;
begin
@@ -2453,11 +2450,16 @@ package body Sem_Warn is
return False;
end Has_Visible_Entities;
+ -- Local variables
+
+ Ent : Entity_Id;
+ Item : Node_Id;
+ Lunit : Entity_Id;
+ Pack : Entity_Id;
+
-- Start of processing for Check_One_Unit
begin
- Cnode := Cunit (Unit);
-
-- Only do check in units that are part of the extended main unit.
-- This is actually a necessary restriction, because in the case of
-- subprogram acting as its own specification, there can be with's in
@@ -2576,7 +2578,7 @@ package body Sem_Warn is
if Unit = Spec_Unit then
Set_No_Entities_Ref_In_Spec (Item);
- elsif Check_System_Aux then
+ elsif Check_System_Aux (Lunit) then
null;
-- Else the warning may be needed