Browse Source

* m68k/n68kmat.pas, tm68knotnode.pass_generate_code:
It is a bad idea (TM) to do a second_pass twice on the same node
* added test

git-svn-id: trunk@22785 -

svenbarth 12 years ago
parent
commit
72a01f17f5
3 changed files with 50 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 9 2
      compiler/m68k/n68kmat.pas
  3. 40 0
      tests/tbs/tb0584.pp

+ 1 - 0
.gitattributes

@@ -9661,6 +9661,7 @@ tests/tbs/tb0581.pp svneol=native#text/plain
 tests/tbs/tb0582.pp svneol=native#text/pascal
 tests/tbs/tb0583.pp svneol=native#text/plain
 tests/tbs/tb0583a.pp svneol=native#text/plain
+tests/tbs/tb0584.pp svneol=native#text/pascal
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain

+ 9 - 2
compiler/m68k/n68kmat.pas

@@ -69,6 +69,7 @@ implementation
       var
          hl : tasmlabel;
          opsize : tcgsize;
+         seconddone : boolean;
       begin
          opsize:=def_cgsize(resultdef);
          if is_boolean(resultdef) then
@@ -77,7 +78,12 @@ implementation
             { if it is a register variable, so we've to do      }
             { this before the case statement                    }
             if left.location.loc<>LOC_JUMP then
-             secondpass(left);
+              begin
+                secondpass(left);
+                seconddone:=true;
+              end
+            else
+              seconddone:=false;
 
             case left.location.loc of
               LOC_JUMP :
@@ -86,7 +92,8 @@ implementation
                   hl:=current_procinfo.CurrTrueLabel;
                   current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;
                   current_procinfo.CurrFalseLabel:=hl;
-                  secondpass(left);
+                  if not seconddone then
+                    secondpass(left);
                   maketojumpbool(current_asmdata.CurrAsmList,left,lr_load_regvars);
                   hl:=current_procinfo.CurrTrueLabel;
                   current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;

+ 40 - 0
tests/tbs/tb0584.pp

@@ -0,0 +1,40 @@
+{ %NORUN }
+
+program tb0584;
+
+{$mode objfpc}
+
+type
+  TSomeObj = class
+    function Test(s: String): TObject;
+  end;
+
+  TSomeOtherObj = class
+  public
+    function GetFoo: String;
+  end;
+
+function TSomeObj.Test(s: String): TObject;
+begin
+
+end;
+
+function TSomeOtherObj.GetFoo: String;
+begin
+
+end;
+
+var
+  SomeObj: TSomeObj;
+
+procedure Test;
+var
+  b: Boolean;
+  obj: TSomeOtherObj;
+begin
+  b := not Assigned(SomeObj.Test(obj.GetFoo));
+end;
+
+begin
+
+end.