diff --git a/.gitattributes b/.gitattributes index dc311d3731..4c5f0ef32a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6461,6 +6461,7 @@ tests/webtbs/tw4675.pp svneol=native#text/plain tests/webtbs/tw4678.pp -text tests/webtbs/tw4700.pp svneol=native#text/plain tests/webtbs/tw4704.pp -text +tests/webtbs/tw4705.pp svneol=native#text/plain tests/webtbs/tw4722.pp svneol=native#text/plain tests/webtbs/tw4763.pp svneol=native#text/plain tests/webtbs/tw4768.pp -text diff --git a/compiler/pstatmnt.pas b/compiler/pstatmnt.pas index 820a262d12..1d11deff0b 100644 --- a/compiler/pstatmnt.pas +++ b/compiler/pstatmnt.pas @@ -125,6 +125,12 @@ implementation caseexpr:=comp_expr(true); { determines result type } do_resulttypepass(caseexpr); + { variants must be accepted, but first they must be converted to integer } + if caseexpr.resulttype.def.deftype=variantdef then + begin + caseexpr:=ctypeconvnode.create_internal(caseexpr,sinttype); + do_resulttypepass(caseexpr); + end; set_varstate(caseexpr,vs_read,[vsf_must_be_valid]); casedeferror:=false; casedef:=caseexpr.resulttype.def; diff --git a/tests/webtbs/tw4705.pp b/tests/webtbs/tw4705.pp new file mode 100644 index 0000000000..998fb92059 --- /dev/null +++ b/tests/webtbs/tw4705.pp @@ -0,0 +1,21 @@ +{ Source provided for Free Pascal Bug Report 4705 } +{ Submitted by "Phil H." on 2006-01-17 } +{ e-mail: pjhess@purdue.edu } +program TestVarCase; + +uses + SysUtils, + Variants; + +var + AVar : Variant; + e : (e1,e2); + +begin + AVar := 1; + case AVar of + 1 : halt(0); + end; + halt(1); +end. +