mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-28 12:43:41 +01:00
* convert inc/dec(pointertype) to add/sub if overflow checking is turned on
(fixes web bug #4004) git-svn-id: trunk@136 -
This commit is contained in:
parent
a7d57f0268
commit
0115a0a38e
@ -2152,9 +2152,10 @@ implementation
|
|||||||
{ range/overflow checking doesn't work properly }
|
{ range/overflow checking doesn't work properly }
|
||||||
{ with the inc/dec code that's generated (JM) }
|
{ with the inc/dec code that's generated (JM) }
|
||||||
(
|
(
|
||||||
(left.resulttype.def.deftype = orddef) and
|
(((left.resulttype.def.deftype = orddef) and
|
||||||
not(is_char(left.resulttype.def)) and
|
not(is_char(left.resulttype.def)) and
|
||||||
not(is_boolean(left.resulttype.def)) and
|
not(is_boolean(left.resulttype.def))) or
|
||||||
|
(left.resulttype.def.deftype = pointerdef)) and
|
||||||
(aktlocalswitches * [cs_check_overflow,cs_check_range] <> [])
|
(aktlocalswitches * [cs_check_overflow,cs_check_range] <> [])
|
||||||
) then
|
) then
|
||||||
{ convert to simple add (JM) }
|
{ convert to simple add (JM) }
|
||||||
@ -2171,7 +2172,10 @@ implementation
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
{ no, create constant 1 }
|
{ no, create constant 1 }
|
||||||
hpp := cordconstnode.create(1,tcallparanode(left).left.resulttype,false);
|
if (tcallparanode(left).left.resulttype.def.deftype <> pointerdef) then
|
||||||
|
hpp := cordconstnode.create(1,tcallparanode(left).left.resulttype,false)
|
||||||
|
else
|
||||||
|
hpp := cordconstnode.create(1,ptrinttype,false);
|
||||||
{ make sure we don't call functions part of the left node twice (and generally }
|
{ make sure we don't call functions part of the left node twice (and generally }
|
||||||
{ optimize the code generation) }
|
{ optimize the code generation) }
|
||||||
if node_complexity(tcallparanode(left).left) > 1 then
|
if node_complexity(tcallparanode(left).left) > 1 then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user