From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c2f4e8127f6a9fd3 X-Google-Attributes: gid103376,public From: Tucker Taft Subject: Re: Renaming entries? Date: 1999/02/23 Message-ID: <36D2FAE5.55F5A4AE@averstar.com>#1/1 X-Deja-AN: 447585364 Content-Transfer-Encoding: 7bit Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.burl.averstar.com References: <7aelgt$2hr$1@nnrp1.dejanews.com> Content-Type: text/plain; charset=us-ascii Organization: AverStar (formerly Intermetrics) Burlington, MA USA Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-02-23T00:00:00+00:00 List-Id: 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