* only allow automatic type conversions of array constructors of

char to pchar/array of char, rather than of arbitrary array
    constructors (mantis #9085)

git-svn-id: trunk@7670 -
This commit is contained in:
Jonas Maebe 2007-06-15 17:16:44 +00:00
parent b293a9bdd4
commit ba95cc22ee
3 changed files with 36 additions and 2 deletions

1
.gitattributes vendored
View File

@ -8295,6 +8295,7 @@ tests/webtbs/tw8950.pp svneol=native#text/plain
tests/webtbs/tw8975.pp svneol=native#text/plain
tests/webtbs/tw8975a.pp svneol=native#text/plain
tests/webtbs/tw9054.pp svneol=native#text/plain
tests/webtbs/tw9085.pp svneol=native#text/plain
tests/webtbs/ub1873.pp svneol=native#text/plain
tests/webtbs/ub1883.pp svneol=native#text/plain
tests/webtbs/uw0555.pp svneol=native#text/plain

View File

@ -848,7 +848,11 @@ implementation
begin
{ string constant (which can be part of array constructor)
to zero terminated string constant }
if (fromtreetype in [arrayconstructorn,stringconstn]) and
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
(is_pchar(def_to) or is_pwidechar(def_to)) then
begin
doconv:=tc_cstring_2_pchar;
@ -937,7 +941,11 @@ implementation
begin
{ string constant (which can be part of array constructor)
to zero terminated string constant }
if (fromtreetype in [arrayconstructorn,stringconstn]) and
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
(is_pchar(def_to) or is_pwidechar(def_to)) then
begin
doconv:=tc_cstring_2_pchar;

25
tests/webtbs/tw9085.pp Normal file
View File

@ -0,0 +1,25 @@
program chatserver;
{$mode objfpc}
procedure Sendln(MsgType: Longint; Str: PChar);
begin
halt(1);
end;
procedure Sendln(MsgType: Longint; Str: array of PChar);
begin
halt(0);
end;
procedure Sendln(MsgType: Longint; Str: array of char);
begin
halt(1);
end;
begin
Sendln(1, ['str1', 'str2'])
end.