* call the ansistring version of val for zero-based array-of-char

parameters (because they can be auto-converted to ansistring, but not
    to shortstring) (mantis #8148)

git-svn-id: trunk@6076 -
This commit is contained in:
Jonas Maebe 2007-01-19 18:22:03 +00:00
parent 3e153102a8
commit a3f059bc29
3 changed files with 29 additions and 0 deletions

1
.gitattributes vendored
View File

@ -7975,6 +7975,7 @@ tests/webtbs/tw8140g.pp svneol=native#text/plain
tests/webtbs/tw8140h.pp svneol=native#text/plain
tests/webtbs/tw8141.pp svneol=native#text/plain
tests/webtbs/tw8145.pp svneol=native#text/plain
tests/webtbs/tw8148.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

@ -1050,6 +1050,9 @@ implementation
{ the shortstring-longint val routine by default }
if (sourcepara.resultdef.typ = stringdef) then
procname := procname + tstringdef(sourcepara.resultdef).stringtypname
{ zero-based arrays (of char) can be implicitely converted to ansistring }
else if is_zero_based_array(sourcepara.resultdef) then
procname := procname + 'ansistr'
else
procname := procname + 'shortstr';

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

@ -0,0 +1,25 @@
program ValVsArrayOfChar;
{$IFDEF FPC}
{$mode delphi}
{$ENDIF}
procedure test(a: ansistring);
begin
end;
var
Code : Integer;
D : Double;
s : Array[byte] of Char;
begin
s := '123';
test(s);
Val(s, D, Code); // compiles only in delphi
if (abs(d-123.0) > 0.00001) then
halt(1);
Val(PChar(@s), D, Code); // compiles in both delphi and FPC
if (abs(d-123.0) > 0.00001) then
halt(1);
end.