diff --git a/.gitattributes b/.gitattributes index 578ad27855..40e294957d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11009,6 +11009,11 @@ tests/test/tcpstr22.pp svneol=native#text/pascal tests/test/tcpstr23.pp svneol=native#text/pascal tests/test/tcpstr24.pp svneol=native#text/plain tests/test/tcpstr25.pp svneol=native#text/plain +tests/test/tcpstr26.pp svneol=native#text/plain +tests/test/tcpstr26a.pp svneol=native#text/plain +tests/test/tcpstr26b.pp svneol=native#text/plain +tests/test/tcpstr26c.pp svneol=native#text/plain +tests/test/tcpstr26d.pp svneol=native#text/plain tests/test/tcpstr2a.pp svneol=native#text/plain tests/test/tcpstr3.pp svneol=native#text/plain tests/test/tcpstr4.pp svneol=native#text/plain diff --git a/compiler/defcmp.pas b/compiler/defcmp.pas index 3446be40d8..c3891a55cb 100644 --- a/compiler/defcmp.pas +++ b/compiler/defcmp.pas @@ -1178,7 +1178,7 @@ implementation (is_pchar(def_to) or is_pwidechar(def_to)) then begin doconv:=tc_cchar_2_pchar; - if is_char(def_from)=is_pchar(def_to) then + if is_pwidechar(def_to)=(m_default_unicodestring in current_settings.modeswitches) then eq:=te_convert_l1 else eq:=te_convert_l2 diff --git a/tests/test/tcpstr26.pp b/tests/test/tcpstr26.pp new file mode 100644 index 0000000000..c473c8c1c7 --- /dev/null +++ b/tests/test/tcpstr26.pp @@ -0,0 +1,18 @@ +{$ifdef fpc} +{$mode delphi} +{$endif} + +procedure test(p: pchar); overload; +begin + writeln('pchar'); +end; + +procedure test(p: pwidechar); overload; +begin + writeln('pwidechar'); + halt(1); +end; + +begin + test('a'); +end. diff --git a/tests/test/tcpstr26a.pp b/tests/test/tcpstr26a.pp new file mode 100644 index 0000000000..fe5bafcecf --- /dev/null +++ b/tests/test/tcpstr26a.pp @@ -0,0 +1,18 @@ +{$ifdef fpc} +{$mode delphiunicode} +{$endif} + +procedure test(p: pansichar); overload; +begin + writeln('pchar'); + halt(1); +end; + +procedure test(p: pwidechar); overload; +begin + writeln('pwidechar'); +end; + +begin + test('a'); +end. diff --git a/tests/test/tcpstr26b.pp b/tests/test/tcpstr26b.pp new file mode 100644 index 0000000000..7685424ea1 --- /dev/null +++ b/tests/test/tcpstr26b.pp @@ -0,0 +1,18 @@ +{$ifdef fpc} +{$mode delphi} +{$endif} + +procedure test(p: pansichar); overload; +begin + writeln('pchar'); +end; + +procedure test(p: pwidechar); overload; +begin + writeln('pwidechar'); + halt(1); +end; + +begin + test(#$1234); +end. diff --git a/tests/test/tcpstr26c.pp b/tests/test/tcpstr26c.pp new file mode 100644 index 0000000000..ed53a28801 --- /dev/null +++ b/tests/test/tcpstr26c.pp @@ -0,0 +1,18 @@ +{$ifdef fpc} +{$mode delphiunicode} +{$endif} + +procedure test(p: pansichar); overload; +begin + writeln('pchar'); + halt(1); +end; + +procedure test(p: pwidechar); overload; +begin + writeln('pwidechar'); +end; + +begin + test(#$1234); +end. diff --git a/tests/test/tcpstr26d.pp b/tests/test/tcpstr26d.pp new file mode 100644 index 0000000000..e3bffb86c1 --- /dev/null +++ b/tests/test/tcpstr26d.pp @@ -0,0 +1,18 @@ +{$ifdef fpc} +{$mode delphiunicode} +{$endif} + +procedure test(p: pansichar); overload; +begin + writeln('pchar'); + halt(1); +end; + +procedure test(p: pwidechar); overload; +begin + writeln('pwidechar'); +end; + +begin + test('abcdef'); +end.