summaryrefslogtreecommitdiff
path: root/tests/tbs
diff options
context:
space:
mode:
authorsvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-01-21 21:30:10 +0000
committersvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-01-21 21:30:10 +0000
commit409f98e673d95fb67ee2276544d5cf567e4ef1b1 (patch)
tree7f060d706113f40675449568bfd0c7e052b65cc7 /tests/tbs
parentdb9b0b2f7877d73da7d6a64995e3620bfbe2143f (diff)
downloadfpc-409f98e673d95fb67ee2276544d5cf567e4ef1b1.tar.gz
* also allow by-value open array parameters for the tail recursion optimization
* adjusted test git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@44012 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'tests/tbs')
-rw-r--r--tests/tbs/tb0667.pp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/tbs/tb0667.pp b/tests/tbs/tb0667.pp
index 0fcc4ceba6..5e293aafcf 100644
--- a/tests/tbs/tb0667.pp
+++ b/tests/tbs/tb0667.pp
@@ -56,6 +56,23 @@ begin
Test3 := Test3(Values, 0);
end;
+function Test4(Values: array of LongInt; Res: LongInt): LongInt;
+begin
+ if not Assigned(stack) then
+ stack := get_frame
+ else if stack <> get_frame then
+ Halt(7);
+ if Length(Values) = 0 then
+ Test4 := Res
+ else
+ Test4 := Test4(Values[0..High(Values) - 1], Res + Values[High(Values)]);
+end;
+
+function Test4(Values: array of LongInt): LongInt;
+begin
+ Test4 := Test4(Values, 0);
+end;
+
begin
if Test1([1, 2, 3, 4]) <> 10 then
Halt(2);
@@ -65,5 +82,8 @@ begin
stack := Nil;
if Test3([1, 2, 3, 4]) <> 10 then
Halt(6);
+ stack := Nil;
+ if Test4([1, 2, 3, 4]) <> 10 then
+ Halt(8);
writeln('ok');
end.