Kaynağa Gözat

Merged revisions 3016 via svnmerge from
http://[email protected]/svn/fpc/trunk

........
r3016 | jonas | 2006-03-22 22:32:48 +0100 (Wed, 22 Mar 2006) | 4 lines

* load a dummy value on the fpu stack in the epilog of functions
which return a real but which never assigned anything to the function
result (since the caller will pop it off again) (x86-only, bug #4902)

........

git-svn-id: branches/fixes_2_0@3082 -

peter 19 yıl önce
ebeveyn
işleme
d47739add1
3 değiştirilmiş dosya ile 26 ekleme ve 1 silme
  1. 1 0
      .gitattributes
  2. 9 1
      compiler/ncgutil.pas
  3. 16 0
      tests/webtbs/tw4902.pp

+ 1 - 0
.gitattributes

@@ -6454,6 +6454,7 @@ tests/webtbs/tw4893a.pp svneol=native#text/plain
 tests/webtbs/tw4893b.pp svneol=native#text/plain
 tests/webtbs/tw4893c.pp svneol=native#text/plain
 tests/webtbs/tw4898.pp -text
+tests/webtbs/tw4902.pp -text
 tests/webtbs/tw4950.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain

+ 9 - 1
compiler/ncgutil.pas

@@ -1223,7 +1223,15 @@ implementation
               else
                 internalerror(200405025);
             end;
-         end;
+          end
+{$ifdef x86}
+         else
+          begin
+            { the caller will pop a value off the cpu stack }
+            if (funcretloc.loc = LOC_FPUREGISTER) then
+              list.concat(taicpu.op_none(A_FLDZ));
+          end;
+{$endif x86}
       end;
 
 

+ 16 - 0
tests/webtbs/tw4902.pp

@@ -0,0 +1,16 @@
+{ Source provided for Free Pascal Bug Report 4902 }
+{ Submitted by "Yu Hang" on  2006-03-14 }
+{ e-mail: [email protected] }
+function x:real;
+begin
+end;
+
+begin
+x;
+{anything here}
+ writeln(1);
+ writeln(2);
+ writeln(3);
+{crash here}
+writeln(1.0)
+end.