diff --git a/.gitattributes b/.gitattributes index 690ccb54f4..008154f462 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/compiler/nset.pas b/compiler/nset.pas index 9cc8d58149..94870d0166 100644 --- a/compiler/nset.pas +++ b/compiler/nset.pas @@ -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 } diff --git a/tests/webtbs/tw4223.pp b/tests/webtbs/tw4223.pp new file mode 100755 index 0000000000..06434869f6 --- /dev/null +++ b/tests/webtbs/tw4223.pp @@ -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.