comp.lang.ada
 help / color / mirror / Atom feed
* Elaboration query
@ 2010-07-23  0:17 (see below)
  2010-07-23  2:10 ` Adam Beneschan
  0 siblings, 1 reply; 3+ messages in thread
From: (see below) @ 2010-07-23  0:17 UTC (permalink / raw)


I have a package which is a grandchild, and GNAT issues elaboration warnings
on its body, thus:

> with IOC.shift; pragma Elaborate_All(IOC.shift);
> package body IOC.shift.TR is
> ...
>    overriding
>    procedure Initialize (the_reader : in out IOC.shift.TR.device) is
>    begin
>       ...
>       open(...);
>       |
>>>> info: call to "open" during elaboration
>>>> info: implicit pragma Elaborate_All for "IO" generated
>>>> warning: "Initialize" called at line 31
>>>> warning: call to "open" in elaboration code requires pragma Elaborate_All
>>>> on "IO"
>    ...
>    end Initialize; ...
> end IOC.shift.TR;

The "open" operation it is complaining about is in the the IO package.

The ancestors of IOC.shift.TR begin thus:

> with IOC; pragma Elaborate_All(IOC);
> package IOC.shift is ...

and:

> with IO; pragma Elaborate_All(IO);
> package IOC is ...

How do I get rid of the warning?

I cannot put an explicit "pragma Elaborate_All(IO)" in IOC.shift.TR, because
it does not "with" IO.

Surely I should not have to "with" IO all the way down the parent/child
hierarchy? What am I doing wrong?

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Elaboration query
  2010-07-23  0:17 Elaboration query (see below)
@ 2010-07-23  2:10 ` Adam Beneschan
  2010-07-23 14:52   ` (see below)
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Beneschan @ 2010-07-23  2:10 UTC (permalink / raw)


On Jul 22, 5:17 pm, "(see below)" <yaldni...@blueyonder.co.uk> wrote:
> I have a package which is a grandchild, and GNAT issues elaboration warnings
> on its body, thus:
>
>
>
>
>
> > with IOC.shift; pragma Elaborate_All(IOC.shift);
> > package body IOC.shift.TR is
> > ...
> >    overriding
> >    procedure Initialize (the_reader : in out IOC.shift.TR.device) is
> >    begin
> >       ...
> >       open(...);
> >       |
> >>>> info: call to "open" during elaboration
> >>>> info: implicit pragma Elaborate_All for "IO" generated
> >>>> warning: "Initialize" called at line 31
> >>>> warning: call to "open" in elaboration code requires pragma Elaborate_All
> >>>> on "IO"
> >    ...
> >    end Initialize; ...
> > end IOC.shift.TR;
>
> The "open" operation it is complaining about is in the the IO package.
>
> The ancestors of IOC.shift.TR begin thus:
>
> > with IOC; pragma Elaborate_All(IOC);
> > package IOC.shift is ...
>
> and:
>
> > with IO; pragma Elaborate_All(IO);
> > package IOC is ...
>
> How do I get rid of the warning?
>
> I cannot put an explicit "pragma Elaborate_All(IO)" in IOC.shift.TR, because
> it does not "with" IO.
>
> Surely I should not have to "with" IO all the way down the parent/child
> hierarchy? What am I doing wrong?

If you want to reference "IO" in a pragma in the context clause, then
yes, you do have to WITH it in the same context clause.  This is
because the visibility rules are different in context clauses.  See
10.1.6, especially 10.1.6(3).  I can understand why you think you
"shouldn't have to" do this, because you don't have to do it when
referencing IO inside the child package body.  But the rules are
different here.  Sorry.

                                 -- Adam



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Elaboration query
  2010-07-23  2:10 ` Adam Beneschan
@ 2010-07-23 14:52   ` (see below)
  0 siblings, 0 replies; 3+ messages in thread
From: (see below) @ 2010-07-23 14:52 UTC (permalink / raw)


On 23/07/2010 03:10, in article
b8dcce8d-979d-4347-a84f-a2a15a318285@m35g2000prn.googlegroups.com, "Adam
Beneschan" <adam@irvine.com> wrote:

> On Jul 22, 5:17�pm, "(see below)" <yaldni...@blueyonder.co.uk> wrote:
>> I have a package which is a grandchild, and GNAT issues elaboration warnings
>> on its body, thus:
>> 
>> 
>> 
>> 
>> 
>>> with IOC.shift; pragma Elaborate_All(IOC.shift);
>>> package body IOC.shift.TR is
>>> ...
>>> � �overriding
>>> � �procedure Initialize (the_reader : in out IOC.shift.TR.device) is
>>> � �begin
>>> � � � ...
>>> � � � open(...);
>>> � � � |
>>>>>> info: call to "open" during elaboration
>>>>>> info: implicit pragma Elaborate_All for "IO" generated
>>>>>> warning: "Initialize" called at line 31
>>>>>> warning: call to "open" in elaboration code requires pragma Elaborate_All
>>>>>> on "IO"
>>> � �...
>>> � �end Initialize; ...
>>> end IOC.shift.TR;
>> 
>> The "open" operation it is complaining about is in the the IO package.
>> 
>> The ancestors of IOC.shift.TR begin thus:
>> 
>>> with IOC; pragma Elaborate_All(IOC);
>>> package IOC.shift is ...
>> 
>> and:
>> 
>>> with IO; pragma Elaborate_All(IO);
>>> package IOC is ...
>> 
>> How do I get rid of the warning?
>> 
>> I cannot put an explicit "pragma Elaborate_All(IO)" in IOC.shift.TR, because
>> it does not "with" IO.
>> 
>> Surely I should not have to "with" IO all the way down the parent/child
>> hierarchy? What am I doing wrong?
> 
> If you want to reference "IO" in a pragma in the context clause, then
> yes, you do have to WITH it in the same context clause.  This is
> because the visibility rules are different in context clauses.  See
> 10.1.6, especially 10.1.6(3).  I can understand why you think you
> "shouldn't have to" do this, because you don't have to do it when
> referencing IO inside the child package body.  But the rules are
> different here.  Sorry.

Thanks, Adam.

BTW the code is part of an emulator for the English Electric KDF9 computer
(announced 1960). It's about 19 KSLOC, so a non-trivial Ada 2005 program.

See <http://www.findlayw.plus.com/KDF9>.

This week it passed a strenuous test, correctly compiling and running the
famous Whetstone Benchmark (which originated, in Algol 60, on the KDF9).

Amusingly, the output was validated by also running the test on a virtual
ICL 1904A, which dates from about 1970; but the 1904A emulator was written
(by Bill Gallagher) in C++.

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-07-23 14:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-23  0:17 Elaboration query (see below)
2010-07-23  2:10 ` Adam Beneschan
2010-07-23 14:52   ` (see below)

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