mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 21:48:09 +02:00
* don't transform div-by-power-of-2 into a shift when overflow checking is
enabled (mantis #23849) git-svn-id: trunk@26089 -
This commit is contained in:
parent
f02dd9fde9
commit
b6d279d4aa
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -13590,6 +13590,7 @@ tests/webtbs/tw2377.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2378.pp svneol=native#text/plain
|
||||
tests/webtbs/tw23819.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2382.pp svneol=native#text/plain
|
||||
tests/webtbs/tw23849.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2388.pp svneol=native#text/plain
|
||||
tests/webtbs/tw23912.pp svneol=native#text/plain
|
||||
tests/webtbs/tw23962.pp svneol=native#text/plain
|
||||
|
@ -71,13 +71,14 @@ implementation
|
||||
var
|
||||
power : longint;
|
||||
begin
|
||||
if (right.nodetype=ordconstn) and
|
||||
(nodetype=divn) and
|
||||
(ispowerof2(tordconstnode(right).value,power) or
|
||||
(tordconstnode(right).value=1) or
|
||||
(tordconstnode(right).value=int64(-1))
|
||||
) and
|
||||
not(is_64bitint(resultdef)) then
|
||||
if not(cs_check_overflow in current_settings.localswitches) and
|
||||
(right.nodetype=ordconstn) and
|
||||
(nodetype=divn) and
|
||||
(ispowerof2(tordconstnode(right).value,power) or
|
||||
(tordconstnode(right).value=1) or
|
||||
(tordconstnode(right).value=int64(-1))
|
||||
) and
|
||||
not(is_64bitint(resultdef)) then
|
||||
result:=nil
|
||||
else if ((GenerateThumbCode) and (CPUARM_HAS_THUMB_IDIV in cpu_capabilities[current_settings.cputype])) and
|
||||
(nodetype=divn) and
|
||||
|
23
tests/webtbs/tw23849.pp
Normal file
23
tests/webtbs/tw23849.pp
Normal file
@ -0,0 +1,23 @@
|
||||
{$mode delphi}
|
||||
{$q+}
|
||||
|
||||
function F(N: integer) : integer;
|
||||
var NN : integer;
|
||||
begin
|
||||
NN := N;
|
||||
if NN < 0 then NN := 0 - NN;
|
||||
result := NN;
|
||||
end;
|
||||
|
||||
procedure Crash; cdecl;
|
||||
var
|
||||
N, M : integer;
|
||||
begin
|
||||
N := -10;
|
||||
M := F(N) div 4;
|
||||
end;
|
||||
|
||||
begin
|
||||
Crash;
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user