comp.lang.ada
 help / color / mirror / Atom feed
* Ada95: at clause - 'Address
@ 1996-10-18  0:00 Ramesh Sadasivam
  1996-10-18  0:00 ` Robert A Duff
  1996-10-19  0:00 ` Robert Dewar
  0 siblings, 2 replies; 3+ messages in thread
From: Ramesh Sadasivam @ 1996-10-18  0:00 UTC (permalink / raw)
  Cc: ramesh


In Ada95 I guess the "at clause" has been replaced with the 'Address.
I'm trying to port a piece of software from Ada83 to Ada95, and the "at
clause" is being handled differently by the GNAT compiler. In case 1 it
ignores it (I'm not sure if it will work, as I do not have the complete
software compiled), and in case 2 it complains. Is there any way to get
around this problem.

CASE 1:
-------
The complier does not complain about the following code.

for TWO_INT_REC_TYPE use
--% Bit-rep for 64-bit computations
  record at mod 8;
    INT1     at 0  range 0..31;
--% Bit-rep for first integer of 64-bit computation
    INT2     at 4  range 0..31;
--% Bit-rep for second integer of 64-bit computation
  end record;

function case_one(X : in SYSTEM.ADDRESS;
		  Y : in SYSTEM.ADDRESS) return BOOLEAN is

X_REC : TWO_INT_REC_TYPE;
for X_REC use at X;
	begin
		....
		....
	end case_one;


CASE 2:
------

procedure case_two(
    ITEM       : in SYSTEM.ADDRESS;
    ITEM_COUNT : POSITIVE := 1 ) is

    ITEM_ADDRESS : SYSTEM.ADDRESS := ITEM; 

  begin
    -- LOOP through each item to be byte swapped
    for COUNT in 1 .. ITEM_COUNT
    loop

      -- Perform the byte swap operation
      SWAP:
      declare
        OLD_VALUE : EIGHT_BYTES_TYPE;
        NEW_VALUE : EIGHT_BYTES_TYPE;
-- tried the the following two ways. Both ways are not accepted by the
compiler, and do not work.

        for NEW_VALUE use at ITEM_ADDRESS;
	for NEW_VALUE'ADDRESS use ITEM_ADDRESS;
     
      begin
	.....
	.....
      end;

Please respond directly to my email address (ramesh@eagle.bgm.link.com),
any help/ideas appreciated.


Thanks,

Ramesh




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

* Re: Ada95: at clause - 'Address
  1996-10-18  0:00 Ada95: at clause - 'Address Ramesh Sadasivam
@ 1996-10-18  0:00 ` Robert A Duff
  1996-10-19  0:00 ` Robert Dewar
  1 sibling, 0 replies; 3+ messages in thread
From: Robert A Duff @ 1996-10-18  0:00 UTC (permalink / raw)



In article <3267958B.41C6@erols.com>,
Ramesh Sadasivam  <madurai@erols.com> wrote:
>In Ada95 I guess the "at clause" has been replaced with the 'Address.

The "at clause" still exists, but is considered obsolescent.
"for X use at Y;" means exactly the same thing as "for X'Address use Y;",
but the second syntax is considered preferable.  But if you have
existing Ada 83 code, there is no need to modify it to use the second
syntax.

>    ITEM_ADDRESS : SYSTEM.ADDRESS := ITEM; 

You need to make this a constant.  In your CASE 1, the address was an
'in' parameter, which is a constant, so it worked.  This is not a hard
rule of Ada, but an allowed restriction.  I think the GNAT error message
points you to the right RM paragraph.

The rule is that in portable code, if you want to say "for X'Address use
Y;", make sure Y is a constant, and that it is declared before X.

- Bob




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

* Re: Ada95: at clause - 'Address
  1996-10-18  0:00 Ada95: at clause - 'Address Ramesh Sadasivam
  1996-10-18  0:00 ` Robert A Duff
@ 1996-10-19  0:00 ` Robert Dewar
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Dewar @ 1996-10-19  0:00 UTC (permalink / raw)



Ramesh says

In Ada95 I guess the "at clause" has been replaced with the 'Address.
I'm trying to port a piece of software from Ada83 to Ada95, and the "at
clause" is being handled differently by the GNAT compiler. In case 1 it
ignores it (I'm not sure if it will work, as I do not have the complete
software compiled), and in case 2 it complains. Is there any way to get
around this problem.


I do not believe that GNAT ignores case 1 (Ramesh gives no evidence that
this is the case). If there is such evidence, it is a bug, send along
details to report@gnat.com.

In case 2, it complains because this is a construct that is non-portable
and which is rejected by GNAT. We could be more liberable and allow this,
but do not want to unless we know other Ada 95 compilers will also allow
the non-portable cases. Meanwhile, "is there any way to get around this
problem", sure! Write proper Ada 95 code, and use a previously defined
constant for the address (I am sure you got a quite specific GNAT message
telling you to do this :-)





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

end of thread, other threads:[~1996-10-19  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-18  0:00 Ada95: at clause - 'Address Ramesh Sadasivam
1996-10-18  0:00 ` Robert A Duff
1996-10-19  0:00 ` Robert Dewar

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