* 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 -
This commit is contained in:
Jonas Maebe 2020-09-20 12:43:45 +00:00
parent 9f42931eeb
commit aa75d39ab5
3 changed files with 20 additions and 1 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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
tests/webtbs/tw37780.pp Normal file
View File

@ -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.