Browse Source

* properly detect when we can't take the address of a with-expression
and assign it to a temp in that case (mantis #8141)

git-svn-id: trunk@6071 -

Jonas Maebe 18 years ago
parent
commit
2ad3ef968f
3 changed files with 14 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 3 2
      compiler/pstatmnt.pas
  3. 10 0
      tests/webtbs/tw8141.pp

+ 1 - 0
.gitattributes

@@ -7964,6 +7964,7 @@ tests/webtbs/tw8028.pp svneol=native#text/plain
 tests/webtbs/tw8049.pp svneol=native#text/plain
 tests/webtbs/tw8055.pp svneol=native#text/plain
 tests/webtbs/tw8090.pp svneol=native#text/plain
+tests/webtbs/tw8141.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

+ 3 - 2
compiler/pstatmnt.pas

@@ -508,8 +508,9 @@ implementation
                 calltempnode:=nil;
                 { complex load, load in temp first }
                 newblock:=internalstatements(newstatement);
-                { when right is a call then load it first in a temp }
-                if p.nodetype=calln then
+                { when we can't take the address of p, load it in a temp }
+                { since we may need its address later on                 }
+                if not valid_for_addr(p,false) then
                   begin
                     calltempnode:=ctempcreatenode.create(p.resultdef,p.resultdef.size,tt_persistent,true);
                     addstatement(newstatement,calltempnode);

+ 10 - 0
tests/webtbs/tw8141.pp

@@ -0,0 +1,10 @@
+{ %norun }
+uses
+  Classes, SysUtils;
+
+var
+  List : TList;
+begin
+  with LongRec(Pointer(List.Last)) do
+    lo := 1;
+end.