* fix check for openarray and single element

git-svn-id: trunk@4390 -
This commit is contained in:
peter 2006-08-07 20:36:18 +00:00
parent 80bd513997
commit 4bde345009
3 changed files with 38 additions and 1 deletions

1
.gitattributes vendored
View File

@ -7239,6 +7239,7 @@ tests/webtbs/tw7104.pp svneol=native#text/plain
tests/webtbs/tw7143.pp -text
tests/webtbs/tw7161.pp svneol=native#text/plain
tests/webtbs/tw7195.pp svneol=native#text/plain
tests/webtbs/tw7227.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

@ -586,8 +586,11 @@ implementation
arraydef :
begin
{ open array is also compatible with a single element of its base type }
{ open array is also compatible with a single element of its base type.
the extra check for deftyp is needed because equal defs can also return
true if the def types are not the same, for example with dynarray to pointer. }
if is_open_array(def_to) and
(def_to.deftype=tarraydef(def_to).elementtype.def.deftype) and
equal_defs(def_from,tarraydef(def_to).elementtype.def) then
begin
doconv:=tc_equal;

33
tests/webtbs/tw7227.pp Normal file
View File

@ -0,0 +1,33 @@
program openarray;
{$ifdef fpc}{$mode delphi}{$endif}
type
PDouble = ^Double;
function CheckValues(values : array of PDouble) : boolean;
var i : integer;
begin
Result := True;
for i := Low(values) to High(values) do
if values[i]^ = 0 then
Result := False;
end;
var values : array of PDouble;
i : integer;
begin
SetLength(values, 5);
for i := 0 to High(values) do
begin
New(values[i]);
values[i]^ := i+1;
end;
for i := 0 to High(values) do
writeln(values[i]^);
if CheckValues(values) then
WriteLn('OK')
else
writeln('not OK');
end.