* 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:
Jonas Maebe 2005-05-29 11:19:40 +00:00
parent a7d57f0268
commit 0115a0a38e

View File

@ -2152,9 +2152,10 @@ implementation
{ range/overflow checking doesn't work properly }
{ with the inc/dec code that's generated (JM) }
(
(left.resulttype.def.deftype = orddef) and
not(is_char(left.resulttype.def)) and
not(is_boolean(left.resulttype.def)) and
(((left.resulttype.def.deftype = orddef) and
not(is_char(left.resulttype.def)) and
not(is_boolean(left.resulttype.def))) or
(left.resulttype.def.deftype = pointerdef)) and
(aktlocalswitches * [cs_check_overflow,cs_check_range] <> [])
) then
{ convert to simple add (JM) }
@ -2171,7 +2172,10 @@ implementation
end
else
{ 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 }
{ optimize the code generation) }
if node_complexity(tcallparanode(left).left) > 1 then