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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7f8b2fd444c211b5 X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Help: pragma inline Date: 1997/05/29 Message-ID: <338D95E7.2469@gsfc.nasa.gov>#1/1 X-Deja-AN: 244733069 References: Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Reply-To: Stephen.Leake@gsfc.nasa.gov Newsgroups: comp.lang.ada Date: 1997-05-29T00:00:00+00:00 List-Id: "Adrian B.Y. Hoe" wrote: function Has_Trail (T : Trail) return Boolean begin return T.Start_In; end Trail_Is_In; pragma Inline(Has_Trail); -- Line 193 OA gives a warning message on line 193: Pragma Inline may not occur after the subprogram body, ignoring pragma inline on this subp. Jeff Creem (jcreem@mailgw.sanders.lockheed.com) wrote: For some reason, all of the compilers based on the AdaMajic front end (ObjectAda and Green Hills Ada 95..Possibly more) want a function or procedure spec used in conjunction with the pragma inline. Tucker Taft wrote: One reason is that the language rules do not allow a program unit pragma, such as pragma inline, following the subprogram body. See RM95 10.1.5(6). For "some reason," GNAT does not enforce this rule ;-). Note that the AdaMagic-based compilers do not as yet support the ability to place the pragma Inline immediately inside a subprogram body, as allowed by 10.1.5(5), so there is still some work to do. But allowing it after the subprogram body is not likely to happen. For what it is worth, the reason a pragma Inline must be given before the subprogram body is that the compiler only saves the statements of the body if a pragma inline applies. Otherwise it discards the statements as soon as code for the subprogram is generated. I write (Stephen Leake): RM95 10.1.5(6) says a program unit pragma is allowed: (6) At the place of a declaration other than the first, of a declarative_part or program unit declaration, in which case the pragma shall have an argument, which shall be a direct_name that denotes one or more of the following (and nothing else): a subprogram_declaration, a generic_subprogram_declaration, or a generic_instantiation, of the same declarative_part or program unit declaration. Suppose I write: function Has_Trail (T : integer) return Boolean; function Has_Trail (T : integer) return Boolean is begin return T = 1; end Has_Trail; pragma Inline(Has_Trail); Does Has_Trail in the pragma name the body or the declaration? GNAT says this is ok, and I don't have Object Ada here (yet). I don't see anything in 10.1.5(6) about being BEFORE anything. I'll admit I'm not clear what "other than the first" is for. I guess GNAT saves a pointer to the source file, rather than a copy of the source? -- - Stephe