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,d3447e1f384e2115 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Placement of pragma Convention Date: 1997/06/23 Message-ID: #1/1 X-Deja-AN: 252077033 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <5oervk$g07@newshub.atmnet.net> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1997-06-23T00:00:00+00:00 List-Id: Christopher Green (cgreen@yosemite.atc.com) wrote: : I have a question concerning the correct placement of pragma Convention; : in particular, whether GNAT and other Ada 95 compilers are properly inter- : preting the applicable rules. : Given the following code: : package Callbacks is : procedure OrdinaryProc; : end Callbacks; : package body Callbacks is : procedure OrdinaryProc is : begin : null; : end OrdinaryProc; : procedure CallbackProc is : begin : null; : end CallbackProc; : pragma Convention (C, CallbackProc); : end Callbacks; : I get the following different results when it is compiled on different Ada 95 : compilers. All compilers are self-hosted on a SPARC/Solaris 2.5 host. : Apex 2.2.3A gives no errors and no warnings. : ObjectAda V7.1 gives no errors and no warnings. : GNAT 3.09 gives the following error: : callbacks.adb:12:05: pragma "Convention" requires separate spec and : must come before body : It would appear to me that the Apex and ObjectAda compilers are correct and : the GNAT compiler is incorrect, ... Despite my affiliation, GNAT is in the right on this one. A program unit pragma may follow the program unit only if the program unit is a subprogram_declaration, generic_subprogram_declaration, or generic instantiation (10.1.5(4,6)). In all other cases, it needs to be immediately inside the program unit. Although a "subprogram_body" is considered to be a "declaration," it is *not* within the category "subprogram_declaration," and so any program unit pragma must be immediately inside it, rather than following it. Amusingly enough, at least in the recent past, Object Ada enforced this rule for pragma Inline (which is also a program unit pragma) and GNAT did not. : ... : Any "language lawyers" interested in commenting on the above, please respond : by posting to this newsgroup or by e-mail. See above. : Chris Green Email cgreen@atc.com : Advanced Technology Center Phone (714) 583-9119 : 22982 Mill Creek Drive ext. 220 : Laguna Hills, CA 92653 Fax (714) 583-9213 -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA