comp.lang.ada
 help / color / mirror / Atom feed
From: robert_dewar@my-dejanews.com
Subject: Re: Imported deferred constant with an address clause legal?
Date: 1999/02/20
Date: 1999-02-20T00:00:00+00:00	[thread overview]
Message-ID: <7alddf$vlr$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 36CDFBB2.853482C@lmco.com

In article <36CDFBB2.853482C@lmco.com>,
  Steve Quinlan <steven.quinlan@lmco.com> wrote:

> I'm not a language lawyer, more like a language
> paralegal, but I don't think this will work. If you use
> Pragma Import, an object of that name will
> be expected to get resolved at link time. I think it is
> even illegal to have an address clause for an imported
> object, because the address is supposed to be determined
> at link time when the object is resolved.

Not only is it legal to have an address clause for an
imported object, but it is a standard diction, mentioned
in the reference manual. A lot of people don't know this
particular rule, and it is one of the cases where GNAT
considers it a good idea to give a warning with the
appropriate RM reference :-) :-)

 1. procedure c is
 2.    type r is record
 3.       x : integer := 0;
 4.    end record;
 5.    b : integer;
 6.    c : r;
 7.    for c'address use b'address;
           |
 >>> warning: implicit initialization of "c" may modify "b"
 >>> warning: use pragma Import for "c" to suppress
              initialization (RM B(24))

 8.
 9. begin
10.    null;
11. end;

The RM also suggests the use of pragma Import and an
address clause together to achieve the effect of an
indirect subprogram call (and there is even an ACVC
test to see if you do this right!) This was a common
Ada 83 diction.

The expectation is that if you have a pragma Import and
an address clause, then the address clause overrides the
linker, and the linker is NOT used to resolve the address
in this case.

Robert Dewar
Ada Core Technologies

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  reply	other threads:[~1999-02-20  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-18  0:00 Imported deferred constant with an address clause legal? Rod Chapman
1999-02-19  0:00 ` Steve Quinlan
1999-02-20  0:00   ` robert_dewar [this message]
1999-02-20  0:00     ` Steve Quinlan
1999-02-21  0:00       ` robert_dewar
1999-03-01  0:00 ` Robert A Duff
replies disabled

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