Browse Source

* In genhightree, do typecheckpass later to prevent references to possibly
optimizes away nodes.

git-svn-id: trunk@6994 -

daniel 18 years ago
parent
commit
d4de54402c
1 changed files with 6 additions and 1 deletions
  1. 6 1
      compiler/ncal.pas

+ 6 - 1
compiler/ncal.pas

@@ -608,18 +608,23 @@ implementation
                         end;
                         end;
                       {In the procedure the array range is 0..(upper_bound-lower_bound).}
                       {In the procedure the array range is 0..(upper_bound-lower_bound).}
                       hightree:=caddnode.create(subn,r,l);
                       hightree:=caddnode.create(subn,r,l);
-                      typecheckpass(hightree);
 
 
                       {Replace the rangnode in the tree by its lower_bound, and
                       {Replace the rangnode in the tree by its lower_bound, and
                        dispose the rangenode.}
                        dispose the rangenode.}
                       temp:=Tvecnode(p).right;
                       temp:=Tvecnode(p).right;
                       Tvecnode(p).right:=l.getcopy;
                       Tvecnode(p).right:=l.getcopy;
+
+					  {Typecheckpass can only be performed *after* the l.getcopy since it
+                       can modify the tree, and l is in the hightree.}
+                      typecheckpass(hightree);
+
                       with Trangenode(temp) do
                       with Trangenode(temp) do
                         begin
                         begin
                           left:=nil;
                           left:=nil;
                           right:=nil;
                           right:=nil;
                         end;
                         end;
                       temp.free;
                       temp.free;
+
                       {Tree changed from p[l..h] to p[l], recalculate resultdef.}
                       {Tree changed from p[l..h] to p[l], recalculate resultdef.}
                       p.resultdef:=nil;
                       p.resultdef:=nil;
                       typecheckpass(p);
                       typecheckpass(p);