* add/sub nodes with nf_internal set should not do overflow checking, resolves #30889

* do not convert succ/pred into add/sub nodes if nf_internal is set

git-svn-id: trunk@34896 -
This commit is contained in:
florian 2016-11-13 21:18:39 +00:00
parent 3207a346e1
commit 6d6a45c034
4 changed files with 22 additions and 3 deletions

1
.gitattributes vendored
View File

@ -15250,6 +15250,7 @@ tests/webtbs/tw30706.pp svneol=native#text/plain
tests/webtbs/tw3073.pp svneol=native#text/plain
tests/webtbs/tw3082.pp svneol=native#text/plain
tests/webtbs/tw3083.pp svneol=native#text/plain
tests/webtbs/tw30889.pp svneol=native#text/pascal
tests/webtbs/tw30923.pp svneol=native#text/pascal
tests/webtbs/tw3093.pp svneol=native#text/plain
tests/webtbs/tw3101.pp svneol=native#text/plain

View File

@ -520,7 +520,7 @@ interface
checkoverflow and
(left.resultdef.typ<>pointerdef) and
(right.resultdef.typ<>pointerdef) and
(cs_check_overflow in current_settings.localswitches);
(cs_check_overflow in current_settings.localswitches) and not(nf_internal in flags);
{$ifdef cpu64bitalu}
case nodetype of
@ -714,7 +714,7 @@ interface
checkoverflow and
(left.resultdef.typ<>pointerdef) and
(right.resultdef.typ<>pointerdef) and
(cs_check_overflow in current_settings.localswitches);
(cs_check_overflow in current_settings.localswitches) and not(nf_internal in flags);
if nodetype<>subn then
begin

View File

@ -3472,7 +3472,7 @@ implementation
because it's too complex to handle correctly otherwise }
{$ifndef jvm}
{ enums are class instances in the JVM -> always need conversion }
if ([cs_check_overflow,cs_check_range]*current_settings.localswitches)<>[] then
if (([cs_check_overflow,cs_check_range]*current_settings.localswitches)<>[]) and not(nf_internal in flags) then
{$endif}
begin
{ create constant 1 }
@ -3491,6 +3491,11 @@ implementation
else
hp:=caddnode.create(subn,left,hp);
{ the condition above is not tested for jvm, so we need to avoid overflow checks here
by setting nf_internal for the add/sub node as well }
if nf_internal in flags then
include(hp.flags,nf_internal);
{ assign result of addition }
if not(is_integer(resultdef)) then
inserttypeconv(hp,corddef.create(

13
tests/webtbs/tw30889.pp Normal file
View File

@ -0,0 +1,13 @@
{$OVERFLOWCHECKS+}
{$mode objfpc}
program project1;
var
c: Cardinal;
i: Integer;
begin
i := 1;
for c := 0 to i do
WriteLn(i);
end.