diff mbox

[Ada] Avoid incorrect warning on limited with that item is unreferenced

Message ID 20150107101243.GA14133@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Jan. 7, 2015, 10:12 a.m. UTC
Under certain complex circumstances, a LIMITED WITH clause can result in
an incorrect warning that the with'ed item is not referenced, when in fact
it is referenced. No simple test is available.

Tested on x86_64-pc-linux-gnu, committed on trunk

2015-01-07  Robert Dewar  <dewar@adacore.com>

	* sem_warn.adb (Check_One_Unit): Guard against context item
	with no Entity field.
diff mbox

Patch

Index: sem_warn.adb
===================================================================
--- sem_warn.adb	(revision 219191)
+++ sem_warn.adb	(working copy)
@@ -2350,6 +2350,13 @@ 
             if Nkind (Item) = N_With_Clause
               and then not Implicit_With (Item)
               and then In_Extended_Main_Source_Unit (Item)
+
+              --  Guard for no entity present. Not clear under what conditions
+              --  this happens, but it does occur, and since this is only a
+              --  warning, we just suppress the warning in this case.
+
+              and then Nkind (Name (Item)) in N_Has_Entity
+              and then Present (Entity (Name (Item)))
             then
                Lunit := Entity (Name (Item));