Browse Source

* one more fix for x86 fpu stack swapping (mantis #10757)

git-svn-id: trunk@10199 -
Jonas Maebe 17 years ago
parent
commit
fee257ba81
3 changed files with 37 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 2 1
      compiler/ncgadd.pas
  3. 34 0
      tests/webtbs/tw10757.pp

+ 1 - 0
.gitattributes

@@ -7951,6 +7951,7 @@ tests/webtbs/tw1073.pp svneol=native#text/plain
 tests/webtbs/tw10736.pp svneol=native#text/plain
 tests/webtbs/tw10753.pp svneol=native#text/plain
 tests/webtbs/tw10753a.pp svneol=native#text/plain
+tests/webtbs/tw10757.pp svneol=native#text/plain
 tests/webtbs/tw1081.pp svneol=native#text/plain
 tests/webtbs/tw1090.pp svneol=native#text/plain
 tests/webtbs/tw1092.pp svneol=native#text/plain

+ 2 - 1
compiler/ncgadd.pas

@@ -161,7 +161,8 @@ interface
                 left.location.register := tmpreg;
 {$ifdef x86}
                 { left operand is now on top of the stack, instead of the right one! }
-                toggleflag(nf_swapped);
+                if (right.location.loc=LOC_FPUREGISTER) then
+                  toggleflag(nf_swapped);
 {$endif x86}
               end;
           end;

+ 34 - 0
tests/webtbs/tw10757.pp

@@ -0,0 +1,34 @@
+{$MODE Objfpc}
+
+type
+  Ta = class 
+    T: array of Double;
+  end;
+
+var
+  a: Ta;
+
+function P:Ta;
+begin
+  Result := a;
+end;
+
+function M: Double;
+begin
+  Result := 300;
+end;
+
+var
+  i: Integer;
+
+begin
+  a := Ta.Create;
+  SetLength(P.T,2);
+  P.T[0] := 70;
+  P.T[1] := 80;
+  i := 0;
+  while (i < Length(P.T)) and (M > P.T[i]) do
+    Inc(i);
+  if (i<>2) then
+    halt(1);
+end.