From: Adam Beneschan on
On Dec 16, 10:54 am, Georg Bauhaus <rm.dash-bauh...(a)futureapps.de>
wrote:

> My idea, possibly confused, is that somehow the
> formal parameter F of generic package Q is not made visible
> in Parent.Child.
>
> With LRM 95 12.7(10) in mind,
>
> generic
>    with package P is new Q (<>);
>    ...
> package Parent...
>
> means, I think, that the parameters for which (<>) stands
> are included in visibility decisions.
>
> >http://www.adapower.com/adapower1/rm95/arm95_187.html
>
> (The paragraph numbering on that page is a bit different from
> what is normally used in the RM. (10) means the tenth paragraph
> which happens to be "Static Semantics, 2nd", on adapower.com)

Be careful here. (10) is not necessarily the tenth paragraph, because
additions to the languages have caused paragraphs to be inserted,
which are then given numbers like (4.1), (5.1), etc. In the Ada 2005
manual, 12.7(10) is actually the 18th paragraph of section 12.7. The
RM available at www.adaic.org/standards has the official paragraph
numbers.

> "The visible part of a formal package includes the first
> list of basic_declarative_items of the package_specification.
> In addition, if the formal_package_actual_part is (<>),
> it also includes the generic_formal_part of the template
> for the formal package.">
> P is the formal package with formal_package_actual_part (<>).
> Q is the template, F is in Qs generic_format_part.
> So F should be as visible as anything specified in P.
> But I'm a layman, hopefully some expert can explain all this

You're right that F should be as visible as anything else visible in
P. The official rule in Ada 2005 is "for each actual parameter that
is not required to match, a copy of the declaration of the
corresponding formal parameter of the template is included in the
visible part of the formal package." Thus, in the declaration

with package P is new Q(<>);

the formal package P will have copies of T and F in the visible part
of P, in addition to the other stuff copied from the visible part of
Q. Thus, "use P" should make T and F directly visible just as other
declarations in the visible part of P would be directly visible.

In answer to your previous question: Ada 2005 did change this, but it
extended this by allowing generic formal packages in which some formal
parameters were required to match but others were not. This change
didn't affect the semantics of formal packages that were legal in Ada
95.

-- Adam

From: Randy Brukardt on
"Andrea Taverna" <a.tavs(a)hotmail.it> wrote in message
news:02e4d172-0eb9-4c2a-ac0f-68e151916d59(a)o19g2000vbj.googlegroups.com...
....
>-----%<-----%<-----%<-----%<-----%<
>]# gnatmake main.adb
>gcc -c main.adb
>main.adb:9:05: instantiation error at parent-child.adb:6
>main.adb:9:05: "F" is not visible (more references follow)
>main.adb:9:05: instantiation error at parent-child.adb:6
>main.adb:9:05: non-visible declaration at q.ads:3
>gnatmake: "main.adb" compilation error
>-----%<-----%<-----%<-----%<-----%<

I haven't studied this code carefully, but this error message suggests to me
that the compiler has a bug. An instantiation should never, ever be illegal
because of something that occurs in the body of the generic. Legality rules
don't apply to generic bodies at instantiation time (only when the generic
unit is compiled).

It's possible that the compiler has delayed the compilation of the body to
the point of the instantation, but even then, the error (if there is one,
and I don't think there is) belongs to the body, not the instantiation. So
at the very least the error message is misleading.

So I suggest reporting this to your vendor and see what they say. (And I'm
glad I'm not your vendor in this case, 'cause I wouldn't want to have to
debug this one. ;-)

Randy.




From: Ludovic Brenta on
Randy Brukardt wrote on comp.lang.ada:
> "Andrea Taverna" wrote:
> >-----%<-----%<-----%<-----%<-----%<
> >]# gnatmake main.adb
> >gcc -c main.adb
> >main.adb:9:05: instantiation error at parent-child.adb:6
> >main.adb:9:05: "F" is not visible (more references follow)
> >main.adb:9:05: instantiation error at parent-child.adb:6
> >main.adb:9:05: non-visible declaration at q.ads:3
> >gnatmake: "main.adb" compilation error
> >-----%<-----%<-----%<-----%<-----%<
>
> I haven't studied this code carefully, but this error message suggests to me
> that the compiler has a bug. An instantiation should never, ever be illegal
> because of something that occurs in the body of the generic. Legality rules
> don't apply to generic bodies at instantiation time (only when the generic
> unit is compiled).
>
> It's possible that the compiler has delayed the compilation of the body to
> the point of the instantation, but even then, the error (if there is one,
> and I don't think there is) belongs to the body, not the instantiation. So
> at the very least the error message is misleading.
>
> So I suggest reporting this to your vendor and see what they say. (And I'm
> glad I'm not your vendor in this case, 'cause I wouldn't want to have to
> debug this one. ;-)

Could it be http://gcc.gnu.org/PR16078 ? This has just been brought to
my attention.

--
Ludovic Brenta.