public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Spurious use visibility with limited with and child packages
@ 2016-10-12 12:57 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2016-10-12 12:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: Justin Squirek

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

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  <squirek@adacore.com>

	* sem_ch10.adb (Remove_Limited_With_Clause): Add a check to
	detect accidental visibility.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 717 bytes --]

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-12 12:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-12 12:57 [Ada] Spurious use visibility with limited with and child packages Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).