瀏覽代碼

* handle loc_jump/loc_flags in for-loop upper bound (mantis #15169)

git-svn-id: trunk@14261 -
Jonas Maebe 15 年之前
父節點
當前提交
d644fc87a1
共有 3 個文件被更改,包括 37 次插入2 次删除
  1. 1 0
      .gitattributes
  2. 19 2
      compiler/ncgflw.pas
  3. 17 0
      tests/webtbs/tw15169.pp

+ 1 - 0
.gitattributes

@@ -10090,6 +10090,7 @@ tests/webtbs/tw14958a.pp svneol=native#text/plain
 tests/webtbs/tw14958b.pp svneol=native#text/plain
 tests/webtbs/tw1501.pp svneol=native#text/plain
 tests/webtbs/tw15088.pp svneol=native#text/plain
+tests/webtbs/tw15169.pp svneol=native#text/plain
 tests/webtbs/tw1532.pp svneol=native#text/plain
 tests/webtbs/tw1539.pp svneol=native#text/plain
 tests/webtbs/tw1567.pp svneol=native#text/plain

+ 19 - 2
compiler/ncgflw.pas

@@ -424,7 +424,8 @@ implementation
 
     procedure tcgfornode.pass_generate_code;
       var
-         l3,oldclabel,oldblabel : tasmlabel;
+         l3,oldclabel,oldblabel,
+         otl, ofl : tasmlabel;
          temptovalue : boolean;
          hop : topcg;
          hcond : topcmp;
@@ -433,6 +434,7 @@ implementation
          cmp_const:Tconstexprint;
          oldflowcontrol : tflowcontrol;
          oldexecutionweight : longint;
+         isjump: boolean;
       begin
          location_reset(location,LOC_VOID,OS_NO);
          oldclabel:=current_procinfo.CurrContinueLabel;
@@ -454,7 +456,22 @@ implementation
          }
            and not(assigned(entrylabel));
 
-         secondpass(t1);
+        isjump:=(t1.expectloc=LOC_JUMP);
+        if isjump then
+          begin
+             otl:=current_procinfo.CurrTrueLabel;
+             current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
+             ofl:=current_procinfo.CurrFalseLabel;
+             current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
+          end;
+        secondpass(t1);
+        if t1.location.loc in [LOC_FLAGS,LOC_JUMP] then
+          location_force_reg(current_asmdata.CurrAsmList,t1.location,def_cgsize(t1.resultdef),false);
+        if isjump then
+          begin
+            current_procinfo.CurrTrueLabel:=otl;
+            current_procinfo.CurrFalseLabel:=ofl;
+          end;
          { calculate pointer value and check if changeable and if so }
          { load into temporary variable                       }
          if t1.nodetype<>ordconstn then

+ 17 - 0
tests/webtbs/tw15169.pp

@@ -0,0 +1,17 @@
+
+type
+  TDragHandleStyle = (dhDouble, dhNone, dhSingle);
+
+
+var b : boolean;
+    fdraghandlestyle : TDraghandlestyle;
+    i : longint;
+begin
+  i:=0;
+  FDraghandlestyle:=dhDouble;
+  for B := False to (FDragHandleStyle = dhDouble) do 
+   inc(i);
+  if (i<>2) then
+    halt(1);
+end.
+