From 3dd32daa036794b2c070b0bb8b4d7b9260c46503 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Thu, 19 Feb 2009 22:43:59 +0000 Subject: [PATCH] * always create a temp for MacPas objects in with-expressions (mantis #13210) git-svn-id: trunk@12753 - --- .gitattributes | 1 + compiler/pstatmnt.pas | 9 ++++++++- tests/webtbs/tw13210.pp | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw13210.pp diff --git a/.gitattributes b/.gitattributes index 5183754e89..bca093f360 100644 --- a/.gitattributes +++ b/.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 diff --git a/compiler/pstatmnt.pas b/compiler/pstatmnt.pas index f06cbb3209..b96184a9d0 100644 --- a/compiler/pstatmnt.pas +++ b/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; diff --git a/tests/webtbs/tw13210.pp b/tests/webtbs/tw13210.pp new file mode 100644 index 0000000000..c5d3ae3aec --- /dev/null +++ b/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.