summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_warn.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-10 10:35:01 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-10 10:35:01 +0000
commit284a54ba02ea14f46eb7f5da50463ac49350731d (patch)
tree08f19541b2e232c7ac20c6ccc5c406ae9ee8e99f /gcc/ada/sem_warn.adb
parent14de9547e6e3387ebde7a7bae28e42881c7b9810 (diff)
downloadgcc-284a54ba02ea14f46eb7f5da50463ac49350731d.tar.gz
2009-04-10 Vincent Celier <celier@adacore.com>
* prj-nmsc.adb (Check_Naming_Schemes): Initialize local variable Casing to avoid gcc warning. 2009-04-10 Robert Dewar <dewar@adacore.com> * g-comlin.adb: Add ??? comment 2009-04-10 Ed Schonberg <schonberg@adacore.com> * sem_warn.adb (Check_Unused_Withs): Do not emit message about unreferenced entities for a package with no visible declarations. 2009-04-10 Robert Dewar <dewar@adacore.com> * exp_ch9.adb: Minor reformatting git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145886 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_warn.adb')
-rw-r--r--gcc/ada/sem_warn.adb48
1 files changed, 47 insertions, 1 deletions
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index 10611743d85..076355b7cd0 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -1887,6 +1887,11 @@ package body Sem_Warn is
-- warn that the context clause could be moved to the body, because
-- the renaming may be intended to re-export the unit.
+ function Has_Visible_Entities (P : Entity_Id) return Boolean;
+ -- If a package has no declared entities, inhibit warning because
+ -- there is nothing to be referenced. The package may be in the
+ -- context just in order to carry a linker pragma for example.
+
-------------------------
-- Check_Inner_Package --
-------------------------
@@ -2011,6 +2016,47 @@ package body Sem_Warn is
return Empty;
end Find_Package_Renaming;
+ --------------------------
+ -- Has_Visible_Entities --
+ --------------------------
+
+ function Has_Visible_Entities (P : Entity_Id) return Boolean is
+ E : Entity_Id;
+
+ begin
+
+ -- If unit in context is not a package, it is a subprogram that
+ -- is not called or a generic unit that is not instantiated
+ -- in the current unit, and warning is appropriate.
+
+ if Ekind (P) /= E_Package then
+ return True;
+ end if;
+
+ -- If unit comes from a limited_with clause, look for declaration
+ -- of shadow entities.
+
+ if Present (Limited_View (P)) then
+ E := First_Entity (Limited_View (P));
+ else
+ E := First_Entity (P);
+ end if;
+
+ while Present (E)
+ and then E /= First_Private_Entity (P)
+ loop
+ if Comes_From_Source (E)
+ or else Present (Limited_View (P))
+ then
+ return True;
+ end if;
+
+ Next_Entity (E);
+ end loop;
+
+ return False;
+ end Has_Visible_Entities;
+
-- Start of processing for Check_One_Unit
begin
@@ -2066,7 +2112,7 @@ package body Sem_Warn is
-- Otherwise simple unreferenced message
- else
+ elsif Has_Visible_Entities (Entity (Name (Item))) then
Error_Msg_N
("?unit& is not referenced!", Name (Item));
end if;