Ver Fonte

* 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 -

Jonas Maebe há 13 anos atrás
pai
commit
562b968b16
3 ficheiros alterados com 26 adições e 0 exclusões
  1. 1 0
      .gitattributes
  2. 2 0
      compiler/ninl.pas
  3. 23 0
      tests/webtbs/tw21878.pp

+ 1 - 0
.gitattributes

@@ -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

+ 2 - 0
compiler/ninl.pas

@@ -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 - 0
tests/webtbs/tw21878.pp

@@ -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.