fpc/tests/webtbs/tw17458.pp
Jonas Maebe 94d976bc87 * when simplifying ordinal expressions during inlining, keep the resultdef
that was set during the typecheck pass because typeconversion nodes
    may have been optimised away previously and sometimes the resultdef is
    important (e.g. for the value of callparanodes) (mantis #17458)

git-svn-id: trunk@16101 -
2010-10-07 15:08:52 +00:00

20 lines
377 B
ObjectPascal

function TailRecFibonacci(const n: Byte): QWord;
function InnerFibo(const n: Byte; const r1,r2: QWord): QWord; inline;
begin
case n of
0: InnerFibo := r1;
1: InnerFibo := r2;
else InnerFibo := InnerFibo(n - 1,r2,r1 + r2);
end;
end;
begin
TailRecFibonacci := InnerFibo(n,0,1);
end;
begin
if TailRecFibonacci(10)<>55 then
halt(1);
end.