Ver código fonte

* always create a temp for MacPas objects in with-expressions (mantis
#13210)

git-svn-id: trunk@12753 -

Jonas Maebe 16 anos atrás
pai
commit
3dd32daa03
3 arquivos alterados com 32 adições e 1 exclusões
  1. 1 0
      .gitattributes
  2. 8 1
      compiler/pstatmnt.pas
  3. 23 0
      tests/webtbs/tw13210.pp

+ 1 - 0
.gitattributes

@@ -8761,6 +8761,7 @@ tests/webtbs/tw1310.pp svneol=native#text/plain
 tests/webtbs/tw13133.pp svneol=native#text/plain
 tests/webtbs/tw1318.pp svneol=native#text/plain
 tests/webtbs/tw13187.pp svneol=native#text/plain
+tests/webtbs/tw13210.pp svneol=native#text/plain
 tests/webtbs/tw1323.pp svneol=native#text/plain
 tests/webtbs/tw1327.pp svneol=native#text/plain
 tests/webtbs/tw1331.pp svneol=native#text/plain

+ 8 - 1
compiler/pstatmnt.pas

@@ -506,7 +506,14 @@ implementation
                 (tloadnode(hp).symtable=current_procinfo.procdef.localst) or
                 (tloadnode(hp).symtable=current_procinfo.procdef.parast) or
                 (tloadnode(hp).symtable.symtabletype in [staticsymtable,globalsymtable])
-               ) then
+               ) and
+               { MacPas objects are mapped to classes, and the MacPas compilers
+                 interpret with-statements with MacPas objects the same way
+                 as records (the object referenced by the with-statement
+                 must remain constant)
+               }
+               not(is_class(hp.resultdef) and
+                   (m_mac in current_settings.modeswitches)) then
               begin
                 { simple load, we can reference direct }
                 refnode:=p;

+ 23 - 0
tests/webtbs/tw13210.pp

@@ -0,0 +1,23 @@
+{$ifdef FPC}
+{$mode macpas}
+{$endif}
+{$ifdef __GPC__}
+{$mac-objects}
+{$endif}
+program withtest2;
+type obj = object i: integer end;
+var p, q, r: obj;
+begin
+    new( p);
+    new( q);
+    p.i:= 1;
+    q.i:= 2;
+    r:= p;
+    with r do
+    begin
+        r:=q;
+        writeln( i);
+        if (i<>1) then
+          halt(1);
+    end
+end.