ソースを参照

* don't perform "(x=y) or (z=u)" -> "(x xor y) or (z xor u)" optimization
if z or u may raise exceptions (mantis #37780)

git-svn-id: trunk@46905 -

Jonas Maebe 4 年 前
コミット
aa75d39ab5
3 ファイル変更20 行追加1 行削除
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/nadd.pas
  3. 18 0
      tests/webtbs/tw37780.pp

+ 1 - 0
.gitattributes

@@ -18471,6 +18471,7 @@ tests/webtbs/tw3768.pp svneol=native#text/plain
 tests/webtbs/tw3774.pp svneol=native#text/plain
 tests/webtbs/tw3777.pp svneol=native#text/plain
 tests/webtbs/tw3778.pp svneol=native#text/plain
+tests/webtbs/tw37780.pp svneol=native#text/plain
 tests/webtbs/tw3780.pp svneol=native#text/plain
 tests/webtbs/tw3782.pp svneol=native#text/plain
 tests/webtbs/tw3796.pp svneol=native#text/plain

+ 1 - 1
compiler/nadd.pas

@@ -1348,7 +1348,7 @@ implementation
                    (left.nodetype=equaln) and
                    (right.nodetype=equaln) and
                    (not might_have_sideeffects(left)) and
-                   (not might_have_sideeffects(right)) and
+                   (not might_have_sideeffects(right,[mhs_exceptions])) and
                    (is_constintnode(taddnode(left).left) or is_constintnode(taddnode(left).right) or
                     is_constpointernode(taddnode(left).left) or is_constpointernode(taddnode(left).right) or
                     is_constcharnode(taddnode(left).left) or is_constcharnode(taddnode(left).right)) and

+ 18 - 0
tests/webtbs/tw37780.pp

@@ -0,0 +1,18 @@
+program testbug;
+
+type
+  PTestRec = ^TTestRec;
+  TTestRec = record
+    Val: Integer;
+    Next: PTestRec;
+  end;
+
+var
+  TR: TTestRec;
+
+begin
+  TR.Val := 6;
+  TR.Next := nil;
+  if (TR.Val = 10) or ((TR.Val = 5) and (TR.Next^.Val = 5)) then
+    Writeln('OK');
+end.