* Legality: formal packages with controlled types
@ 2001-11-24 17:39 Simon Wright
2001-11-24 18:22 ` Jeffrey Carter
2001-11-28 11:29 ` Simon Wright
0 siblings, 2 replies; 4+ messages in thread
From: Simon Wright @ 2001-11-24 17:39 UTC (permalink / raw)
The code below fails on OA 7.2 with
bug.ada: Error: line 21 col 42 LRM:3.9.1(3), The accessibility level
of a record extension shall not exceed that of its parent; this
also applies in a generic instantiation (In instance of generic
base at bug.ada: line 7 col 7)
and similar code fails similarly on OA 7.2.1 and AdaMULTI v3.1 I'm
told. Presumably they all share a front end.
The code compiles OK if Base.Container isn't derived from Controlled.
Is it really the case that it's legal to instantiate a generic package
with a package that contains a controlled type but illegal to
instantiate a generic subprogram?
========================================================
with ada.finalization;
generic
type item is private;
package base is
type container is tagged private;
private
type container is new ada.finalization.controlled with record
the_item : item;
end record;
end base;
with base;
generic
type item is private;
with package New_Base is new base (item); -- <==== ok
package Generic_package is end Generic_package;
with base;
generic
type item is private;
with package new_base is new base (item); -- <==== failure
procedure Generic_Procedure;
procedure generic_procedure is
begin
null;
end generic_procedure;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Legality: formal packages with controlled types
2001-11-24 17:39 Legality: formal packages with controlled types Simon Wright
@ 2001-11-24 18:22 ` Jeffrey Carter
2001-11-25 10:38 ` Simon Wright
2001-11-28 11:29 ` Simon Wright
1 sibling, 1 reply; 4+ messages in thread
From: Jeffrey Carter @ 2001-11-24 18:22 UTC (permalink / raw)
The code compiles without error with GNAT 3.13p/Win98.
--
Jeff Carter
"Perfidious English mouse-dropping hoarders."
Monty Python & the Holy Grail
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Legality: formal packages with controlled types
2001-11-24 18:22 ` Jeffrey Carter
@ 2001-11-25 10:38 ` Simon Wright
0 siblings, 0 replies; 4+ messages in thread
From: Simon Wright @ 2001-11-25 10:38 UTC (permalink / raw)
Jeffrey Carter <jrcarter@acm.org> writes:
> The code compiles without error with GNAT 3.13p/Win98.
Yes, I know, but I have found that sometimes OA is right under these
circumstances!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Legality: formal packages with controlled types
2001-11-24 17:39 Legality: formal packages with controlled types Simon Wright
2001-11-24 18:22 ` Jeffrey Carter
@ 2001-11-28 11:29 ` Simon Wright
1 sibling, 0 replies; 4+ messages in thread
From: Simon Wright @ 2001-11-28 11:29 UTC (permalink / raw)
Simon Wright <simon@pushface.org> writes:
> The code below fails on OA 7.2 with
>
> bug.ada: Error: line 21 col 42 LRM:3.9.1(3), The accessibility level
> of a record extension shall not exceed that of its parent; this
> also applies in a generic instantiation (In instance of generic
> base at bug.ada: line 7 col 7)
>
> and similar code fails similarly on OA 7.2.1 and AdaMULTI v3.1 I'm
> told. Presumably they all share a front end.
>
> The code compiles OK if Base.Container isn't derived from Controlled.
>
> Is it really the case that it's legal to instantiate a generic package
> with a package that contains a controlled type but illegal to
> instantiate a generic subprogram?
>
> ========================================================
> with ada.finalization;
> generic
> type item is private;
> package base is
> type container is tagged private;
> private
> type container is new ada.finalization.controlled with record
> the_item : item;
> end record;
> end base;
>
> with base;
> generic
> type item is private;
> with package New_Base is new base (item); -- <==== ok
> package Generic_package is end Generic_package;
>
> with base;
> generic
> type item is private;
> with package new_base is new base (item); -- <==== failure
> procedure Generic_Procedure;
>
> procedure generic_procedure is
> begin
> null;
> end generic_procedure;
I'm informed by ACT that this code is legal and that the compilers
that reject it (which, BTW, include Apex) are wrong to do so.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-11-28 11:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-24 17:39 Legality: formal packages with controlled types Simon Wright
2001-11-24 18:22 ` Jeffrey Carter
2001-11-25 10:38 ` Simon Wright
2001-11-28 11:29 ` Simon Wright
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox