comp.lang.ada
 help / color / mirror / Atom feed
From: ytomino <aghia05@gmail.com>
Subject: question about visibility rule for renamed generic package
Date: Sat, 6 Aug 2011 00:01:36 -0700 (PDT)
Date: 2011-08-06T00:01:36-07:00	[thread overview]
Message-ID: <c4c98ead-5494-42b8-a0fb-98d930c161c2@y8g2000prd.googlegroups.com> (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.



                 reply	other threads:[~2011-08-06  7:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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