mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-22 15:29:25 +02:00
* 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:
parent
b293a9bdd4
commit
ba95cc22ee
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8295,6 +8295,7 @@ tests/webtbs/tw8950.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw8975.pp svneol=native#text/plain
|
tests/webtbs/tw8975.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw8975a.pp svneol=native#text/plain
|
tests/webtbs/tw8975a.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw9054.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/ub1873.pp svneol=native#text/plain
|
||||||
tests/webtbs/ub1883.pp svneol=native#text/plain
|
tests/webtbs/ub1883.pp svneol=native#text/plain
|
||||||
tests/webtbs/uw0555.pp svneol=native#text/plain
|
tests/webtbs/uw0555.pp svneol=native#text/plain
|
||||||
|
@ -848,7 +848,11 @@ implementation
|
|||||||
begin
|
begin
|
||||||
{ string constant (which can be part of array constructor)
|
{ string constant (which can be part of array constructor)
|
||||||
to zero terminated string constant }
|
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
|
(is_pchar(def_to) or is_pwidechar(def_to)) then
|
||||||
begin
|
begin
|
||||||
doconv:=tc_cstring_2_pchar;
|
doconv:=tc_cstring_2_pchar;
|
||||||
@ -937,7 +941,11 @@ implementation
|
|||||||
begin
|
begin
|
||||||
{ string constant (which can be part of array constructor)
|
{ string constant (which can be part of array constructor)
|
||||||
to zero terminated string constant }
|
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
|
(is_pchar(def_to) or is_pwidechar(def_to)) then
|
||||||
begin
|
begin
|
||||||
doconv:=tc_cstring_2_pchar;
|
doconv:=tc_cstring_2_pchar;
|
||||||
|
25
tests/webtbs/tw9085.pp
Normal file
25
tests/webtbs/tw9085.pp
Normal 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.
|
Loading…
Reference in New Issue
Block a user