diff --git a/.gitattributes b/.gitattributes index a6c4a4e271..5a058aff5a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6007,6 +6007,7 @@ tests/webtbs/tw4240.pp svneol=native#text/plain tests/webtbs/tw4247.pp svneol=native#text/plain tests/webtbs/tw4253.pp svneol=native#text/plain tests/webtbs/tw4260.pp svneol=native#text/plain +tests/webtbs/tw4272.pp svneol=native#text/plain tests/webtbs/tw4277.pp svneol=native#text/plain tests/webtbs/tw4294.pp svneol=native#text/plain tests/webtbs/tw4308.pp svneol=native#text/plain diff --git a/compiler/defcmp.pas b/compiler/defcmp.pas index 14558b01cc..0f996b0091 100644 --- a/compiler/defcmp.pas +++ b/compiler/defcmp.pas @@ -304,23 +304,35 @@ implementation else begin doconv:=tc_string_2_string; - if tstringdef(def_from).string_typ=st_widestring then - begin - { Prefer conversions to shortstring over other - conversions. This is compatible with Delphi (PFV) } - if tstringdef(def_to).string_typ=st_shortstring then - eq:=te_convert_l3 - else - eq:=te_convert_l2; - end - else - { Prefer shortstrings of different length or conversions - from shortstring to ansistring } - if (tstringdef(def_from).string_typ=st_shortstring) and - (tstringdef(def_to).string_typ in [st_shortstring,st_ansistring]) then - eq:=te_convert_l1 - else - eq:=te_convert_l2; + case tstringdef(def_from).string_typ of + st_widestring : + begin + { Prefer conversions to ansistring } + if tstringdef(def_to).string_typ=st_ansistring then + eq:=te_convert_l2 + else + eq:=te_convert_l3; + end; + st_shortstring : + begin + { Prefer shortstrings of different length or conversions + from shortstring to ansistring } + if (tstringdef(def_to).string_typ=st_shortstring) then + eq:=te_convert_l1 + else if tstringdef(def_to).string_typ=st_ansistring then + eq:=te_convert_l2 + else + eq:=te_convert_l3; + end; + st_ansistring : + begin + { Prefer conversion to widestrings } + if (tstringdef(def_to).string_typ=st_widestring) then + eq:=te_convert_l2 + else + eq:=te_convert_l3; + end; + end; end; end; orddef : diff --git a/tests/webtbs/tw4272.pp b/tests/webtbs/tw4272.pp new file mode 100755 index 0000000000..df7842592e --- /dev/null +++ b/tests/webtbs/tw4272.pp @@ -0,0 +1,16 @@ +procedure go(const w: widestring);overload; +begin +writeln('wide: ',w); +end; + +procedure go(const w: shortstring);overload; +begin +writeln('short: ',w); +end; + +var + s: ansistring; +begin + s:='test'; + go(s); //-->compiler can not determine whitch overloaded function to call +end.