Browse Source

* first parameter of SetLength must be valid, as it is read

git-svn-id: trunk@39347 -
florian 7 years ago
parent
commit
9af9658fa7
3 changed files with 17 additions and 3 deletions
  1. 2 1
      .gitattributes
  2. 2 2
      compiler/ninl.pas
  3. 13 0
      tests/tbf/tb0258.pp

+ 2 - 1
.gitattributes

@@ -490,7 +490,7 @@ compiler/ncon.pas svneol=native#text/plain
 compiler/nflw.pas svneol=native#text/plain
 compiler/ngenutil.pas svneol=native#text/plain
 compiler/ngtcon.pas svneol=native#text/plain
-compiler/ninl.pas -text svneol=native#text/plain
+compiler/ninl.pas svneol=native#text/plain
 compiler/nld.pas svneol=native#text/plain
 compiler/nmat.pas -text svneol=native#text/plain
 compiler/nmem.pas svneol=native#text/plain
@@ -10900,6 +10900,7 @@ tests/tbf/tb0255c.pp svneol=native#text/pascal
 tests/tbf/tb0256.pp svneol=native#text/pascal
 tests/tbf/tb0257a.pp svneol=native#text/pascal
 tests/tbf/tb0257b.pp svneol=native#text/pascal
+tests/tbf/tb0258.pp svneol=native#text/pascal
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain

+ 2 - 2
compiler/ninl.pas

@@ -1730,7 +1730,7 @@ implementation
         { last param must be var }
         destppn:=ppn.left;
         valid_for_var(destppn,true);
-        set_varstate(destppn,vs_written,[]);
+        set_varstate(destppn,vs_written,[vsf_must_be_valid]);
         { first param must be a string or dynamic array ...}
         isarray:=is_dynamic_array(destppn.resultdef);
         if not((destppn.resultdef.typ=stringdef) or
@@ -3161,7 +3161,7 @@ implementation
                            else
                              begin
                                hp:=self;
-                               if isunaryoverloaded(hp,[]) then
+                               if isunaryoverloaded(hp,[]) then
                                  begin
                                    { inc(rec) and dec(rec) assigns result value to argument }
                                    result:=cassignmentnode.create(tcallparanode(left).left.getcopy,hp);

+ 13 - 0
tests/tbf/tb0258.pp

@@ -0,0 +1,13 @@
+{ %fail% }
+{ %opt=-Sew -vw }
+
+procedure p;
+var
+  a : array of longint;
+begin
+  setlength(p,100);
+end;
+
+begin
+end.
+