comp.lang.ada
 help / color / mirror / Atom feed
From: Tucker Taft <stt@averstar.com>
Subject: Re: Renaming entries?
Date: 1999/02/23
Date: 1999-02-23T00:00:00+00:00	[thread overview]
Message-ID: <36D2FAE5.55F5A4AE@averstar.com> (raw)
In-Reply-To: 7aelgt$2hr$1@nnrp1.dejanews.com

dennison@telepath.com wrote:
> 
> I don't really understand the error I'm getting, but I'm getting pretty much
> the same error message from 2 different compilers.
> 
> What I'm trying to do is rename a task entry to be a procedure. The procedure
> is declared in the package spec, but the renaming is done in the body. I'm
> wondering if that's my problem. Does a renaming have to be a procedure
> *declaration*, or can it be the completion of a declaration?
> 
> Here's a smallish code sample if you need to see it to answer my question.
> 
> procedure Rename_Test is
> 
>    procedure Fred;
> 
>    task Foo is
>       entry Jim;
>    end Foo;
> 
>    procedure Fred renames Foo.Jim;
> 
>    task body Foo is
>    begin
>       accept Jim;
>    end Foo;
> 
> begin
>    Fred;
> end Rename_Test;
> 
> When compiled with gnat, I get
> rename_test.adb:15:19: not subtype conformant with declaration at line 8
> rename_test.adb:15:19: prior declaration for "Fred" has convention "Ada"

GNAT is wrong in this complaint, because a renaming as body
is always OK so long as the prior subprogram declaration
has not yet been "frozen."  See RM95-8.5.4(5), last sentence.

> The same example compiles OK w/ GreenHills, but not if the declarations are
> moved to a package spec and body. In that case I also get an error referring
> to Fred having convention "Ada".

The Green Hills compiler is correct here.  As written above, the
prior subprogram declaration takes its convention from the renamed
thing (in this case a task entry).  However, if you separate
the subprogram declaration from the renaming-as-body by a freezing
point (like the end of a library package spec), then the
subprogram declaration takes the default convention "Ada" which
doesn't match the "entry" convention of the renaming-as-body.

> Removing the "procedure Fred;" line cause gnat to compile it ok.

That simply makes it a renaming-as-declaration, which is always OK.

In any case, as others have pointed out, creating your own "wrapper"
subprogram, which you then declare "inline," should work in all
circumstances.  Renaming-as-body is a short-hand which works
only when the conventions match up, or when the renaming-as-body
happens before the subprogram declaration is frozen.

> T.E.D.

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




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

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-17  0:00 Renaming entries? dennison
1999-02-17  0:00 ` Nick Roberts
1999-02-17  0:00   ` David Brown
1999-02-18  0:00     ` Nick Roberts
1999-02-18  0:00   ` robert_dewar
1999-02-17  0:00 ` Jean-Pierre Rosen
1999-02-23  0:00 ` Tucker Taft [this message]
replies disabled

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