comp.lang.ada
 help / color / mirror / Atom feed
* Re: Help: pragma inline
  1997-05-20  0:00 Help: pragma inline Adrian B.Y. Hoe
@ 1997-05-20  0:00 ` Robert Dewar
  1997-05-21  0:00 ` Jeff Creem
  1997-05-21  0:00 ` Kevin Krieser
  2 siblings, 0 replies; 6+ messages in thread
From: Robert Dewar @ 1997-05-20  0:00 UTC (permalink / raw)



<<OA gives a warning message on line 193: Pragma Inline may not occur
after the subprogram body, ignoring pragma inline on this subp.

Could anyone explain more about inline and whether the warning could
affect the intention of pragma Inline?

Your help is most valuable.


Thank you in advance.>>


Most probaby OA is ignoring the pragma given the message, and certainly
it is more normal to give the pragma after the spec anyway. But any
compiler is allowed to ignore inline anyway. GNAT allows inline in
this position, but it is very unusual usage (note that a representation
pragma certainly could NOT occur here -- after the freeze point).





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

* Help: pragma inline
@ 1997-05-20  0:00 Adrian B.Y. Hoe
  1997-05-20  0:00 ` Robert Dewar
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Adrian B.Y. Hoe @ 1997-05-20  0:00 UTC (permalink / raw)



I encounter a warning when compiling the following code (fragment)
using ObjectAda 7.0.232


        ...

        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.

Could anyone explain more about inline and whether the warning could
affect the intention of pragma Inline?

Your help is most valuable.


Thank you in advance.



--

B.Y.


lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
 Adrian, B.Y. Hoe                     byHoe@quantum.pc.my           \/
 Business Development, VP                                         \/  \/
                                                                \/  \/  \/
                                      Phone : +60 3 495 4048      \/  \/
 Lexical Integration (M) Sdn Bhd      Fax   : +60 3 495 4037        \/
 13-B Jalan Pandan Indah 4/2, Pandan Indah, 55100 Kuala Lumpur-Malaysia
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
                                          member of Team-Ada in Malaysia




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

* Re: Help: pragma inline
  1997-05-20  0:00 Help: pragma inline Adrian B.Y. Hoe
  1997-05-20  0:00 ` Robert Dewar
  1997-05-21  0:00 ` Jeff Creem
@ 1997-05-21  0:00 ` Kevin Krieser
  2 siblings, 0 replies; 6+ messages in thread
From: Kevin Krieser @ 1997-05-21  0:00 UTC (permalink / raw)



 In message <3381bff2.quantum@quantum.pc.my> - "Adrian B.Y. Hoe"
<byHoe@QUANTUM.PC.MY> writes:
 :>
:>        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.
:>
:>Could anyone explain more about inline and whether the warning could
:>affect the intention of pragma Inline?
:>
:

Is this routine possibly declared in a package spec?

If so, that is where you want to put the Pragma inline.

Otherwise, you might put a function spec earlier in the code, and put the
pragma inline there.

--Because of a large amount of SPAM e-mail, especially following
--postings on the Newsgroups, I have unfortunately had to 
--change my e-mail address in the message headers.  Sorry.





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

* Re: Help: pragma inline
  1997-05-20  0:00 Help: pragma inline Adrian B.Y. Hoe
  1997-05-20  0:00 ` Robert Dewar
@ 1997-05-21  0:00 ` Jeff Creem
  1997-05-27  0:00   ` Tucker Taft
  1997-05-21  0:00 ` Kevin Krieser
  2 siblings, 1 reply; 6+ messages in thread
From: Jeff Creem @ 1997-05-21  0:00 UTC (permalink / raw)



In article <3381bff2.quantum@quantum.pc.my>, "Adrian B.Y. Hoe"
<byHoe@QUANTUM.PC.MY> wrote:

>I encounter a warning when compiling the following code (fragment)
>using ObjectAda 7.0.232
>
>
>        ...
>
>        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.
>
>Could anyone explain more about inline and whether the warning could
>affect the intention of pragma Inline?
>
>Your help is most valuable.
>
>
>Thank you in advance.


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. So
if you are trying to inline a visible procedure/function in a packake
spec no problem just put the inline in the spec (this is the same
as most (all?) other compilers). WHere it gets cumbersome is that it
wants you to create a useless spec even for cases where you dont really
need one. So for example if the above was in a package body do this.

    function Has_Trail (T : Trail) return Boolean;
    pragma Inline(Has_Trail);


    function Has_Trail (T : Trail) return Boolean
    begin
      return T.Start_In;
    end Trail_Is_In;

 
It is silly and a little annoying but it appears to work. (which is
the most important thing)




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

* Re: Help: pragma inline
  1997-05-21  0:00 ` Jeff Creem
@ 1997-05-27  0:00   ` Tucker Taft
  1997-05-29  0:00     ` Stephen Leake
  0 siblings, 1 reply; 6+ messages in thread
From: Tucker Taft @ 1997-05-27  0:00 UTC (permalink / raw)



Jeff Creem (jcreem@mailgw.sanders.lockheed.com) wrote:
: In article <3381bff2.quantum@quantum.pc.my>, "Adrian B.Y. Hoe"

: <byHoe@QUANTUM.PC.MY> wrote:

: >I encounter a warning when compiling the following code (fragment)
: >using ObjectAda 7.0.232
: >
: >
: >        ...
: >
: >        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.
: >
: >Could anyone explain more about inline and whether the warning could
: >affect the intention of pragma Inline?
: >
: >Your help is most valuable.
: >
: >
: >Thank you in advance.

: 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. 

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.

: ...
:     function Has_Trail (T : Trail) return Boolean;
:     pragma Inline(Has_Trail);


:     function Has_Trail (T : Trail) return Boolean
:     begin
:       return T.Start_In;
:     end Trail_Is_In;

:  
: It is silly and a little annoying but it appears to work. (which is
: the most important thing)

It is also the RM way...

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA




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

* Re: Help: pragma inline
  1997-05-27  0:00   ` Tucker Taft
@ 1997-05-29  0:00     ` Stephen Leake
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Leake @ 1997-05-29  0:00 UTC (permalink / raw)



"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




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

end of thread, other threads:[~1997-05-29  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-05-20  0:00 Help: pragma inline Adrian B.Y. Hoe
1997-05-20  0:00 ` Robert Dewar
1997-05-21  0:00 ` Jeff Creem
1997-05-27  0:00   ` Tucker Taft
1997-05-29  0:00     ` Stephen Leake
1997-05-21  0:00 ` Kevin Krieser

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