瀏覽代碼

* do not try to unroll a loop if previously an error was thrown, resolves #37475

git-svn-id: trunk@46435 -
florian 5 年之前
父節點
當前提交
1ba8255af0
共有 3 個文件被更改,包括 12 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 2 0
      compiler/optloop.pas
  3. 9 0
      tests/webtbf/tw37475.pp

+ 1 - 0
.gitattributes

@@ -16558,6 +16558,7 @@ tests/webtbf/tw3738.pp svneol=native#text/plain
 tests/webtbf/tw3740.pp svneol=native#text/plain
 tests/webtbf/tw3740.pp svneol=native#text/plain
 tests/webtbf/tw37460.pp svneol=native#text/pascal
 tests/webtbf/tw37460.pp svneol=native#text/pascal
 tests/webtbf/tw37462.pp svneol=native#text/pascal
 tests/webtbf/tw37462.pp svneol=native#text/pascal
+tests/webtbf/tw37475.pp svneol=native#text/pascal
 tests/webtbf/tw3790.pp svneol=native#text/plain
 tests/webtbf/tw3790.pp svneol=native#text/plain
 tests/webtbf/tw3812.pp svneol=native#text/plain
 tests/webtbf/tw3812.pp svneol=native#text/plain
 tests/webtbf/tw3930a.pp svneol=native#text/plain
 tests/webtbf/tw3930a.pp svneol=native#text/plain

+ 2 - 0
compiler/optloop.pas

@@ -112,6 +112,8 @@ unit optloop;
         result:=nil;
         result:=nil;
         if (cs_opt_size in current_settings.optimizerswitches) then
         if (cs_opt_size in current_settings.optimizerswitches) then
           exit;
           exit;
+        if ErrorCount<>0 then
+          exit;
         if not(node.nodetype in [forn]) then
         if not(node.nodetype in [forn]) then
           exit;
           exit;
         unrolls:=number_unrolls(tfornode(node).t2);
         unrolls:=number_unrolls(tfornode(node).t2);

+ 9 - 0
tests/webtbf/tw37475.pp

@@ -0,0 +1,9 @@
+{ %fail }
+{ %opt=-O3 }
+var a : integer;
+begin
+  for a := 1 to 1 do
+      for a := 1 to a do
+  end;
+end.
+