* no range check for delphi mode with in operator

git-svn-id: trunk@1354 -
This commit is contained in:
peter 2005-10-11 06:46:56 +00:00
parent 6314aa118f
commit 8b1f3d2470
3 changed files with 45 additions and 17 deletions

1
.gitattributes vendored
View File

@ -6301,6 +6301,7 @@ tests/webtbs/tw4201.pp svneol=native#text/plain
tests/webtbs/tw4202.pp svneol=native#text/plain
tests/webtbs/tw4215.pp svneol=native#text/plain
tests/webtbs/tw4219.pp svneol=native#text/plain
tests/webtbs/tw4223.pp svneol=native#text/plain
tests/webtbs/tw4233.pp svneol=native#text/plain
tests/webtbs/tw4240.pp svneol=native#text/plain
tests/webtbs/tw4247.pp svneol=native#text/plain

View File

@ -244,25 +244,33 @@ implementation
if not assigned(left.resulttype.def) then
internalerror(20021126);
{ insert a hint that a range check error might occur on non-byte
elements.with the in operator.
}
if (
(left.resulttype.def.deftype = orddef) and not
(torddef(left.resulttype.def).typ in [s8bit,u8bit,uchar,bool8bit])
)
or
(
(left.resulttype.def.deftype = enumdef) and
(tenumdef(left.resulttype.def).maxval > 255)
)
then
CGMessage(type_h_in_range_check);
{ type conversion/check }
if assigned(tsetdef(right.resulttype.def).elementtype.def) then
if (m_fpc in aktmodeswitches) then
begin
inserttypeconv(left,tsetdef(right.resulttype.def).elementtype);
{ insert a hint that a range check error might occur on non-byte
elements with the in operator.
}
if (
(left.resulttype.def.deftype = orddef) and not
(torddef(left.resulttype.def).typ in [s8bit,u8bit,uchar,bool8bit])
)
or
(
(left.resulttype.def.deftype = enumdef) and
(tenumdef(left.resulttype.def).maxval > 255)
)
then
CGMessage(type_h_in_range_check);
{ type conversion/check }
if assigned(tsetdef(right.resulttype.def).elementtype.def) then
inserttypeconv(left,tsetdef(right.resulttype.def).elementtype);
end
else
begin
{ insert explicit type conversion/check }
if assigned(tsetdef(right.resulttype.def).elementtype.def) then
inserttypeconv_internal(left,tsetdef(right.resulttype.def).elementtype);
end;
{ empty set then return false }

19
tests/webtbs/tw4223.pp Executable file
View File

@ -0,0 +1,19 @@
{ Source provided for Free Pascal Bug Report 4223 }
{ Submitted by "Phil Hess" on 2005-07-25 }
{ e-mail: pjhess@purdue.edu }
program TestSet;
{$Mode delphi}
{$R+}
var
AnInt : Integer;
begin
AnInt := -1;
if AnInt in [1,2,3] then
WriteLn('In set')
else
WriteLn('Not in set');
end.