mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-27 12:10:09 +02:00
* properly transform a+const1-const2 into a+const1+(-const2), resolves #40041
This commit is contained in:
parent
48b9751419
commit
e0fef23d77
@ -1483,7 +1483,7 @@ implementation
|
||||
begin
|
||||
Result:=getcopy;
|
||||
Result.nodetype:=addn;
|
||||
right:=cunaryminusnode.create(right);
|
||||
taddnode(result).right:=cunaryminusnode.create(taddnode(result).right);
|
||||
exit;
|
||||
end;
|
||||
|
||||
|
13
tests/webtbs/tw40041.pp
Normal file
13
tests/webtbs/tw40041.pp
Normal file
@ -0,0 +1,13 @@
|
||||
{$mode objfpc}
|
||||
function Shift(x: single): single; noinline;
|
||||
begin
|
||||
result := x + 10.0 - 1.0;
|
||||
end;
|
||||
|
||||
begin
|
||||
if Shift(5.0) <> 14.0 then
|
||||
begin
|
||||
writeln('Got ', Shift(5.0):0:1, ', expected 14.0.');
|
||||
halt(1);
|
||||
end;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user