This patch corrects a minor issue whereby declarations that occur
immediately within package P are erroneously treated as potentially
use-visible when a parent package has a limited with clause on P, a
child package has a with clause on P, and the child package is a
client of another unit.
------------
-- Source --
------------
-- buffer.ads
package Buffer is
Junk : Integer;
end;
-- d.ads
limited with Buffer;
package D is
Junk : Integer;
end;
-- d-te.ads
with Buffer;
package D.Te is
Junk : Integer;
end;
-- f.ads
with D.Te;
package F is
use Buffer; -- This should cause an error
end;
----------------------------
-- Compilation and output --
----------------------------
$ gcc -c f.ads
f.ads:3:08: "Buffer" is not visible
f.ads:3:08: non-visible declaration at buffer.ads:1
Tested on x86_64-pc-linux-gnu, committed on trunk
2016-10-12 Justin Squirek <[email protected]>
* sem_ch10.adb (Remove_Limited_With_Clause): Add a check to
detect accidental visibility.
Index: sem_ch10.adb
===================================================================
--- sem_ch10.adb (revision 241024)
+++ sem_ch10.adb (working copy)
@@ -6377,6 +6377,13 @@
-- Limited_Withed_Unit.
else
+ -- If the limited_with_clause is in some other unit in the context
+ -- then it is not visible in the main unit.
+
+ if not In_Extended_Main_Source_Unit (N) then
+ Set_Is_Immediately_Visible (P, False);
+ end if;
+
-- Real entities that are type or subtype declarations were hidden
-- from visibility at the point of installation of the limited-view.
-- Now we recover the previous value of the hidden attribute.