* now that copy() expressions are only translated into calls during the

first pass, we have to manually set the varstate of its parameters during
    the typecheck pass (mantis #21878)

git-svn-id: trunk@21106 -
This commit is contained in:
Jonas Maebe 2012-04-28 21:33:29 +00:00
parent be5a5d6ae6
commit 562b968b16
3 changed files with 26 additions and 0 deletions

1
.gitattributes vendored
View File

@ -12567,6 +12567,7 @@ tests/webtbs/tw2178.pp svneol=native#text/plain
tests/webtbs/tw2185.pp svneol=native#text/plain
tests/webtbs/tw2186.pp svneol=native#text/plain
tests/webtbs/tw2187.pp svneol=native#text/plain
tests/webtbs/tw21878.pp svneol=native#text/plain
tests/webtbs/tw2196.pp svneol=native#text/plain
tests/webtbs/tw2197.pp svneol=native#text/plain
tests/webtbs/tw2198.pp svneol=native#text/plain

View File

@ -1599,8 +1599,10 @@ implementation
while assigned(ppn.right) do
begin
inc(counter);
set_varstate(ppn.left,vs_read,[vsf_must_be_valid]);
ppn:=tcallparanode(ppn.right);
end;
set_varstate(ppn.left,vs_read,[vsf_must_be_valid]);
paradef:=ppn.left.resultdef;
if is_ansistring(paradef) then
// set resultdef to argument def

23
tests/webtbs/tw21878.pp Normal file
View File

@ -0,0 +1,23 @@
{ %norun }
{ %opt=-vn -Sen }
{$mode objfpc}{$H+}
uses
Classes, SysUtils;
function DoSomething(const AName: string): integer;
var
i, l: Integer;
begin
Result := 0;;
l := Length(AName);
for i:= 1 to Paramcount do begin
if copy(ParamStr(i),1, l) = AName then
inc(Result);
end;
end;
begin
DoSomething('a');
end.