comp.lang.ada
 help / color / mirror / Atom feed
* Problem with Address Clauses
@ 1995-02-09 18:11 Bob Gilbert
  1995-02-10 15:16 ` Theodore E. Dennison
  1995-02-11 13:57 ` Robert Dewar
  0 siblings, 2 replies; 4+ messages in thread
From: Bob Gilbert @ 1995-02-09 18:11 UTC (permalink / raw)


I believe that I may have posted this problem to the group
some time ago, so I appologize if I'm being somewhat redundant
of if the question was answered earlier, but here goes:

I'm using an Ada '83 compiler that appears to require a "static
expression" for the address clause.  This is preventing me from
implementing generic packages which would provide an interface to
various memory mapped devices, where multiple instances of these
devices might exist for one processor and/or the device may be used 
on several different processors but at different base addresses.
I know that I can "work around" this by using access types and
unchecked conversion to resolve the mapping, but I feel that this
should not be necessary and goes against the spirit of the Ada
language (not portable, etc.). I've used this technique of writing 
generic interfaces to memory mapped devices with several other Ada 
compilers in the past with no problems, and it seems that this is 
an unreasonable limitation of this particular compiler.  Do I have
a valid gripe, or is the compiler vendor within the legal definition 
of the language?  Also, the vendor informs me that this problem will
still exist even with there Ada 95 offerings.  Should I continue
pressing the vendor on this point?

The following is a sample piece of code that highlights the problem:

   with System;
   package Address_Clause is

     type SYSTEM_TYPE is (Ax, Bx);
 
     type BASE_ADDR_ARRAY is array (SYSTEM_TYPE) of SYSTEM.ADDRESS;

     X_Base_Table : constant BASE_ADDR_ARRAY :=
                      BASE_ADDR_ARRAY'(Ax => 16#0020_0000#,
                                       Bx => 16#0010_0000#);

     ---------------------------------------------------------------
     -- Ultimately this package would be implemented as a generic  -
     -- where the array index (Ax) used to identify the system,    -
     -- would be supplied as a generic parameter.  The generic     -
     -- implementation is not shown to avoid unnecessary           -
     -- complications (this comment seems to provides sufficient   -
     -- confusion anyway).                                         -
     ---------------------------------------------------------------
     XBase   : constant SYSTEM.ADDRESS := X_Base_Table(Ax);
     XAddr_1 : constant SYSTEM.ADDRESS := XBase + 0;

     X1 : INTEGER;
       for X1 use at XAddr_1;

   end Address_Clause;


When I compile the above I get the following error:

   ____________________________________________________________________________

     23|  X1 : INTEGER;
     24|    for X1 use at XAddr_1;
                          ^1
   ***  1 Error 3271: A static expression is expected here (4.9) 
     25|
   ____________________________________________________________________________



Thanks in advance for any inputs and opinions,

-Bob




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

* Re: Problem with Address Clauses
  1995-02-09 18:11 Problem with Address Clauses Bob Gilbert
@ 1995-02-10 15:16 ` Theodore E. Dennison
  1995-02-11 13:57 ` Robert Dewar
  1 sibling, 0 replies; 4+ messages in thread
From: Theodore E. Dennison @ 1995-02-10 15:16 UTC (permalink / raw)


rgilbert@orl.mmc.com (Bob Gilbert) wrote:
>
> I believe that I may have posted this problem to the group
> some time ago, so I appologize if I'm being somewhat redundant
> of if the question was answered earlier, but here goes:
> 
> I'm using an Ada '83 compiler that appears to require a "static
> expression" for the address clause.  This is preventing me from
..
> an unreasonable limitation of this particular compiler.  Do I have
> a valid gripe, or is the compiler vendor within the legal definition 
> of the language?  Also, the vendor informs me that this problem will
> still exist even with there Ada 95 offerings.  Should I continue
> pressing the vendor on this point?
> 

Sounds like Alsys. :-)

The LRM (13.5) specifies the part after the "at" must be a "simple 
expression". A static expression would certainly qualify as a simple
expression, but so would a function call (LRM 4.4). I'm not sure how
kosher it is to make your compiler MORE restrictive than the language
specifies. Perhaps one of the compiler folk here can comment on this
one. But it sounds like you have a case to me.

T.E.D.
dennison@orl.mmc.com



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

* Re: Problem with Address Clauses
  1995-02-09 18:11 Problem with Address Clauses Bob Gilbert
  1995-02-10 15:16 ` Theodore E. Dennison
@ 1995-02-11 13:57 ` Robert Dewar
       [not found]   ` <3hsvie$a2u@theopolis.orl.mmc.com>
  1 sibling, 1 reply; 4+ messages in thread
From: Robert Dewar @ 1995-02-11 13:57 UTC (permalink / raw)


Requiring static expressions in address clauses is probably an allowable
restriction given that rep clauses are somewhat impl dependent anyway,
but it is *certainly* an extremely unfriendly restriction. So you may
not be able to sue, but you could switch!




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

* Re: ANSI C allows extensions (was: Problem with Address Clauses)
       [not found]           ` <3idapr$ngb@watnews1.watson.ibm.com>
@ 1995-02-25 21:19             ` Robert Dewar
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1995-02-25 21:19 UTC (permalink / raw)


The SunOS 4.1.3 compiler breaks LOTS of ANSI rules, try looking at 
the result returned by sprintf, or try referencing SEEK_SET (I am
just mentioning two "features
than have burned me in the past!




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

end of thread, other threads:[~1995-02-25 21:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-02-09 18:11 Problem with Address Clauses Bob Gilbert
1995-02-10 15:16 ` Theodore E. Dennison
1995-02-11 13:57 ` Robert Dewar
     [not found]   ` <3hsvie$a2u@theopolis.orl.mmc.com>
     [not found]     ` <3hug0j$f50@felix.seas.gwu.edu>
     [not found]       ` <3hvlbd$pk6@theopolis.orl.mmc.com>
     [not found]         ` <3ibsta$2ub@felix.seas.gwu.edu>
     [not found]           ` <3idapr$ngb@watnews1.watson.ibm.com>
1995-02-25 21:19             ` ANSI C allows extensions (was: Problem with Address Clauses) Robert Dewar

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