comp.lang.ada
 help / color / mirror / Atom feed
* Does `pragma inline` work when instantiating generic code?
@ 2015-07-26 11:15 EGarrulo
  2015-07-26 18:21 ` Georg Bauhaus
  0 siblings, 1 reply; 2+ messages in thread
From: EGarrulo @ 2015-07-26 11:15 UTC (permalink / raw)


Assuming this generic code (see the comment in the second file):

------ negate.ads ------

generic
   with function Predicate return Boolean;
function Negate return Boolean;

------ negate.adb ------

function Negate return Boolean is
begin
   return not Predicate; -- ##### Will the compiler inline this call? ######
end Negate;

------ test.adb ------

procedure Test is
   function My_Predicate return Boolean is begin
     return True;
   end My_Predicate;

   pragma inline(My_Predicate);

   function My_Not_Predicate is new Negate (My_Predicate);
   
   X : Boolean := My_Not_Predicate;
begin
   null;
end Test;

------------------------


Thank you.

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

* Re: Does `pragma inline` work when instantiating generic code?
  2015-07-26 11:15 Does `pragma inline` work when instantiating generic code? EGarrulo
@ 2015-07-26 18:21 ` Georg Bauhaus
  0 siblings, 0 replies; 2+ messages in thread
From: Georg Bauhaus @ 2015-07-26 18:21 UTC (permalink / raw)


On 26.07.15 13:15, EGarrulo wrote:
[Subject]
Yes, inlining works with generics; e.g., the GNAT User's Guide
explains how inlining (which requires optimization) affects
source dependence: inlining needs looking into bodies, thence
of instances. In fact, compiler switches are required for your
original example to produce any instructions at all. as it is devoid
of effects, so no op code needs to be generated.


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

end of thread, other threads:[~2015-07-26 18:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-26 11:15 Does `pragma inline` work when instantiating generic code? EGarrulo
2015-07-26 18:21 ` Georg Bauhaus

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