comp.lang.ada
 help / color / mirror / Atom feed
* question about visibility rule for renamed generic package
@ 2011-08-06  7:01 ytomino
  0 siblings, 0 replies; only message in thread
From: ytomino @ 2011-08-06  7:01 UTC (permalink / raw)


Hello.

A generic child package looking private part of its parent, is
renamed. Can this renamed package look private part of the original
parent, or not ?
I tried and got error with gcc (4.6.1), but I think it should be
compiled...

-- p.ads

package p is
   type t is private;
private
   type t is record
      f : integer;
   end record;
end p;

-- p.child.ads

generic
package p.child is
   type u is new t;
   function get_f (x : u) return Integer;
end p.child;

-- p.child.adb

package body p.child is
   function get_f (x : u) return Integer is
   begin
      return x.f; -- look the private part
   end get_f;
end p.child;

-- renamed.adb

with p.child;
generic
package renamed renames p.child;

-- main.adb

with p.child;
with renamed;
procedure main is

   package instance1 is new p.child;
   -- 1. correct case
   -- it's ok.

   package instance2 is new renamed;
   -- 2. error case
   -- main.adb:9:09: instantiation error at p-child.adb:4
   -- main.adb:9:09: invalid prefix in selected component "x"

begin
   null;
end main;

Thank you.



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

only message in thread, other threads:[~2011-08-06  7:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-06  7:01 question about visibility rule for renamed generic package ytomino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox