[Ada] Cleanup repeated code in checks for unused WITH clauses
gcc/ada/ * sem_warn.adb (Check_One_Unit): Avoid repeated calls by using a local variable Lunit; remove local constant Eitem, which was identical to Lunit.
This commit is contained in:
parent
f5d2432f92
commit
1c583927a5
@ -2507,7 +2507,7 @@ package body Sem_Warn is
|
|||||||
-- package with only a linker options pragma and nothing
|
-- package with only a linker options pragma and nothing
|
||||||
-- else or a pragma elaborate with a body library task).
|
-- else or a pragma elaborate with a body library task).
|
||||||
|
|
||||||
elsif Has_Visible_Entities (Entity (Name (Item))) then
|
elsif Has_Visible_Entities (Lunit) then
|
||||||
Error_Msg_N -- CODEFIX
|
Error_Msg_N -- CODEFIX
|
||||||
("?u?unit& is not referenced!", Name (Item));
|
("?u?unit& is not referenced!", Name (Item));
|
||||||
end if;
|
end if;
|
||||||
@ -2582,29 +2582,22 @@ package body Sem_Warn is
|
|||||||
-- Else the warning may be needed
|
-- Else the warning may be needed
|
||||||
|
|
||||||
else
|
else
|
||||||
declare
|
-- Warn if we unreferenced flag set and we have
|
||||||
Eitem : constant Entity_Id :=
|
-- not had serious errors. The reason we inhibit
|
||||||
Entity (Name (Item));
|
-- the message if there are errors is to prevent
|
||||||
|
-- false positives from disabling expansion.
|
||||||
|
|
||||||
begin
|
if not Has_Unreferenced (Lunit)
|
||||||
-- Warn if we unreferenced flag set and we
|
|
||||||
-- have not had serious errors. The reason we
|
|
||||||
-- inhibit the message if there are errors is
|
|
||||||
-- to prevent false positives from disabling
|
|
||||||
-- expansion.
|
|
||||||
|
|
||||||
if not Has_Unreferenced (Eitem)
|
|
||||||
and then Serious_Errors_Detected = 0
|
and then Serious_Errors_Detected = 0
|
||||||
then
|
then
|
||||||
-- Get possible package renaming
|
-- Get possible package renaming
|
||||||
|
|
||||||
Pack :=
|
Pack := Find_Package_Renaming (Munite, Lunit);
|
||||||
Find_Package_Renaming (Munite, Lunit);
|
|
||||||
|
|
||||||
-- No warning if either the package or its
|
-- No warning if either the package or its
|
||||||
-- renaming is used as a generic actual.
|
-- renaming is used as a generic actual.
|
||||||
|
|
||||||
if Used_As_Generic_Actual (Eitem)
|
if Used_As_Generic_Actual (Lunit)
|
||||||
or else
|
or else
|
||||||
(Present (Pack)
|
(Present (Pack)
|
||||||
and then
|
and then
|
||||||
@ -2633,7 +2626,6 @@ package body Sem_Warn is
|
|||||||
Unit_Declaration_Node (Pack), Pack);
|
Unit_Declaration_Node (Pack), Pack);
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end;
|
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user