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 <[email protected]>
* sem_ch8.adb (Update_Use_Clause_Chain): Add sanity check to verify
scope stack traversal into the context clause.
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;