* Fixed passing of open array of wide string literals to function which expects 'array of pwidechar' parameter in case source file has utf8 encoding. Compiler thrown the following error in such case: Incompatible type for arg no. 1: Got "Array Of Const/Constant Open Array of WideString", expected "Open Array Of PWideChar".

+ Test for this issue.

git-svn-id: trunk@11581 -
This commit is contained in:
yury 2008-08-14 18:55:10 +00:00
parent bf6bf46708
commit 8818df640f
3 changed files with 24 additions and 6 deletions

1
.gitattributes vendored
View File

@ -7137,6 +7137,7 @@ tests/tbs/tb0551.pp svneol=native#text/plain
tests/tbs/tb0552.pp svneol=native#text/plain
tests/tbs/tb0553.pp svneol=native#text/plain
tests/tbs/tb0554.pp svneol=native#text/plain
tests/tbs/tb0555.pp svneol=native#text/plain
tests/tbs/tb205.pp svneol=native#text/plain
tests/tbs/ub0060.pp svneol=native#text/plain
tests/tbs/ub0069.pp svneol=native#text/plain

View File

@ -890,18 +890,14 @@ implementation
begin
{ string constant (which can be part of array constructor)
to zero terminated string constant }
if (((fromtreetype = arrayconstructorn) and
{ can't use is_chararray, because returns false for }
{ array constructors }
is_char(tarraydef(def_from).elementdef)) or
(fromtreetype = stringconstn)) and
if (fromtreetype = stringconstn) and
(is_pchar(def_to) or is_pwidechar(def_to)) then
begin
doconv:=tc_cstring_2_pchar;
eq:=te_convert_l2;
end
else
if cdo_explicit in cdoptions then
if (cdo_explicit in cdoptions) or (fromtreetype = arrayconstructorn) then
begin
{ pchar(ansistring) }
if is_pchar(def_to) and

21
tests/tbs/tb0555.pp Normal file
View File

@ -0,0 +1,21 @@

function DoTest(params: array of PWideChar): WideString;
var
i: integer;
res: WideString;
begin
res:='';
for i:=Low(params) to High(params) do
res:=res + params[i];
DoTest:=res;
end;
var
s: WideString;
begin
s:=DoTest(['аб', 'вг', 'де']);
if s <> 'абвгде' then begin
writeln('Test failed. S=', s);
Halt(1);
end;
end.