* GNAT error? [a generic child instance looses visibility]
@ 2002-03-18 9:56 Dmitry A. Kazakov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry A. Kazakov @ 2002-03-18 9:56 UTC (permalink / raw)
The following code results in GNAT compilation error. I tried to
reduce the code amount as much as possible:
-----------------------------------------------------------------
package Obj is
type X is tagged private;
private
type X is tagged record
Component : Integer; -- Visible for children only
end record;
end Obj;
-----------------------------------------------------------------
generic
type XX is new X with private;
package Obj.Child is
type XX_Handle is tagged private;
procedure Access_Internals (This : XX_Handle);
private
type XX_Ptr is access all XX'Class;
type XX_Handle is tagged record
Ptr : XX_Ptr;
end record;
end Obj.Child;
-----------------------------------------------------------------
package body Obj.Child is
procedure Access_Internals (This : XX_Handle) is
begin
This.Ptr.Component := 0; -- Access the hidden component
end Access_Internals;
end Obj.Child;
-----------------------------------------------------------------
with Obj.Child;
package Test is
type Y_Handle is private;
procedure Crash;
private
type Y is new Obj.X with null record;
type Y_Ptr is access all Y'Class;
package Instantiation is new Obj.Child (Y);
type Y_Handle is new Instantiation.XX_Handle with null record;
end Test;
-----------------------------------------------------------------
package body Test is
procedure Crash is
Var : Y_Handle;
begin
Access_Internals (Var);
end Crash;
end Test;
-----------------------------------------------------------------
GNAT 3.14p (20010503) Copyright 1992-2001 Free Software Foundation,
Inc.
Compiling: d:\home\dmitry\new\tests\new_i~eh\test.adb (source file
time stamp: 2002-03-18 09:44:16)
1. package body Test is
2. procedure Crash is
3. Var : Y_Handle;
4. begin
5. Access_Internals (Var);
6. end Crash;
7. end Test;
==============Error messages for source file:
d:\home\dmitry\new\tests\new_i~eh\test.ads
9. package Instantiation is new Obj.Child (Y);
|
>>> instantiation error at obj-child.adb:4
>>> no selector "Component" for type "Y'Class" defined at line
7
7 lines: 2 errors
It seems that during instantiation Obj.Child.Access_Internals looses
access to X.Component, no matter that it belongs to the child package.
Object Ada successfully compiles the example above. Also, GNAT's bug?
Regards,
Dmitry Kazakov
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: GNAT error? [a generic child instance looses visibility]
@ 2002-03-18 10:10 Christoph Grein
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Grein @ 2002-03-18 10:10 UTC (permalink / raw)
> 9. package Instantiation is new Obj.Child (Y);
> |
> >>> instantiation error at obj-child.adb:4
> >>> no selector "Component" for type "Y'Class" defined at line 7
Looks like a Gnat bug, Rational Apex compiles this.
>
> 7 lines: 2 errors
>
> It seems that during instantiation Obj.Child.Access_Internals looses
> access to X.Component, no matter that it belongs to the child package.
> Object Ada successfully compiles the example above. Also, GNAT's bug?
>
> Regards,
> Dmitry Kazakov
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-03-18 10:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-18 10:10 GNAT error? [a generic child instance looses visibility] Christoph Grein
-- strict thread matches above, loose matches on Subject: below --
2002-03-18 9:56 Dmitry A. Kazakov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox