diff mbox series

[Ada] Spurious ineffective use_clause warning

Message ID 20171020170350.GA112628@adacore.com
State New
Headers show
Series [Ada] Spurious ineffective use_clause warning | expand

Commit Message

Pierre-Marie de Rodat Oct. 20, 2017, 5:03 p.m. UTC
This patch corrects an issue whereby a child package included into the body of
a parent forced checks on ineffective use clauses within the parent's spec to
be checked early - leading to spurious warnings.

------------
-- Source --
------------

--  pp.ads

package PP is
  type Object is null record;
  Undefined : Object;
end;

--  p.ads

with PP;
package P is
   use type PP.Object;
   procedure Force;
end;

--  p.adb

with P.S;
package body P is
   Junk : Boolean := PP.Undefined /= PP.Undefined and P.S.Junk;
   procedure Force is null;
end;

--  p-s.ads

package P.S is
   Junk : Boolean := True;
end;

----------------------------
-- Compilation and output --
----------------------------

& gnatmake -q -gnatwu p.adb

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

2017-10-20  Justin Squirek  <squirek@adacore.com>

	* sem_ch8.adb (Update_Use_Clause_Chain): Add sanity check to verify
	scope stack traversal into the context clause.
diff mbox series

Patch

Index: sem_ch8.adb
===================================================================
--- sem_ch8.adb	(revision 253945)
+++ sem_ch8.adb	(working copy)
@@ -9108,10 +9108,10 @@ 
       --  Deal with use clauses within the context area if the current
       --  scope is a compilation unit.
 
-      if Is_Compilation_Unit (Current_Scope) then
-
-         pragma Assert (Scope_Stack.Last /= Scope_Stack.First);
-
+      if Is_Compilation_Unit (Current_Scope)
+        and then Sloc (Scope_Stack.Table
+                        (Scope_Stack.Last - 1).Entity) = Standard_Location
+      then
          Update_Chain_In_Scope (Scope_Stack.Last - 1);
       end if;
    end Update_Use_Clause_Chain;