Browse Source

Add new tests related to nostackframe checks added in commit 22677

git-svn-id: trunk@22678 -
pierre 13 years ago
parent
commit
1cfb612513
4 changed files with 74 additions and 0 deletions
  1. 3 0
      .gitattributes
  2. 28 0
      tests/test/tnostackframe.pp
  3. 24 0
      tests/test/tnostackframe2.pp
  4. 19 0
      tests/test/tnostackframe3.pp

+ 3 - 0
.gitattributes

@@ -10986,6 +10986,9 @@ tests/test/tnoext4.pp svneol=native#text/plain
 tests/test/tnonlocalgoto1.pp svneol=native#text/pascal
 tests/test/tnonlocalgoto1.pp svneol=native#text/pascal
 tests/test/tnonlocalgoto2.pp svneol=native#text/pascal
 tests/test/tnonlocalgoto2.pp svneol=native#text/pascal
 tests/test/tnonlocalgoto3.pp svneol=native#text/pascal
 tests/test/tnonlocalgoto3.pp svneol=native#text/pascal
+tests/test/tnostackframe.pp svneol=native#text/pascal
+tests/test/tnostackframe2.pp svneol=native#text/pascal
+tests/test/tnostackframe3.pp svneol=native#text/pascal
 tests/test/tobjc1.pp svneol=native#text/plain
 tests/test/tobjc1.pp svneol=native#text/plain
 tests/test/tobjc10.pp svneol=native#text/plain
 tests/test/tobjc10.pp svneol=native#text/plain
 tests/test/tobjc11.pp svneol=native#text/plain
 tests/test/tobjc11.pp svneol=native#text/plain

+ 28 - 0
tests/test/tnostackframe.pp

@@ -0,0 +1,28 @@
+{ %fail }
+{ %opt=-Sew }
+
+{ This is a border case:
+  the result could be considered to reside only in
+  the function result register,
+  in which case no stack space would be required... }
+
+  { This is the reason of the -Sew option,
+    this test must fail because a warning sould be issued
+    about nostackframe without assembler.
+    Please do not remove -Sew option. PM 2012-10-17 }
+
+function test : longint; nostackframe;
+
+begin
+  test:=5;
+end;
+
+begin
+  if test<>5 then
+    begin
+      writeln('Wrong result in  nostackframe non-assembler function');
+      halt(1);
+    end
+  else
+    writeln('Pascal function nostackframe works OK');
+end.

+ 24 - 0
tests/test/tnostackframe2.pp

@@ -0,0 +1,24 @@
+{ %fail }
+{%opt=-O- }
+{ This function defines a local var which needs stack space,
+  so nostackframe should always be invalid.
+  -O- option used because with -O3 both result
+  and x variable can be regvars, so that there is no error! }
+
+function test : longint; nostackframe;
+var
+  x : longint;
+begin
+  x:=4;
+  test:=5*x;
+end;
+
+begin
+  if test<>20 then
+    begin
+      writeln('Wrong result in  nostackframe non-assembler function');
+      halt(1);
+    end
+  else
+    writeln('Pascal function nostackframe works OK');
+end.

+ 19 - 0
tests/test/tnostackframe3.pp

@@ -0,0 +1,19 @@
+
+var
+  x :longint;
+procedure test; nostackframe;
+begin
+  x:=78;
+end;
+
+begin
+  x:=-1;
+  test;
+  if x<>78 then
+    begin
+      writeln('Wrong result in  nostackframe non-assembler procedure');
+      halt(1);
+    end
+  else
+    writeln('Pascal procedure nostackframe works OK');
+end.