* make self-pointer passed by reference not regable. Was not necessary

when we only had objects because they are never put in registers,
    but (advanced) records can be (mantis #21177)

git-svn-id: trunk@20192 -
This commit is contained in:
Jonas Maebe 2012-01-29 11:30:12 +00:00
parent 7c9b93dd91
commit 1f83203117
3 changed files with 36 additions and 0 deletions

1
.gitattributes vendored
View File

@ -12179,6 +12179,7 @@ tests/webtbs/tw2109.pp svneol=native#text/plain
tests/webtbs/tw2110.pp svneol=native#text/plain
tests/webtbs/tw21146.pp svneol=native#text/pascal
tests/webtbs/tw21151.pp svneol=native#text/plain
tests/webtbs/tw21177.pp svneol=native#text/plain
tests/webtbs/tw2128.pp svneol=native#text/plain
tests/webtbs/tw2129.pp svneol=native#text/plain
tests/webtbs/tw2129b.pp svneol=native#text/plain

View File

@ -2337,6 +2337,12 @@ implementation
para.left:=gen_procvar_context_tree
else
para.left:=gen_self_tree;
{ make sure that e.g. the self pointer of an advanced
record does not become a regvar, because it's a vs_var
parameter }
if paramanager.push_addr_param(para.parasym.varspez,para.parasym.vardef,
procdefinition.proccalloption) then
make_not_regable(para.left,[ra_addr_regable]);
end
else
if vo_is_vmt in para.parasym.varoptions then

29
tests/webtbs/tw21177.pp Normal file
View File

@ -0,0 +1,29 @@
{$modeswitch ADVANCEDRECORDS}
{$OPTIMIZATION REGVAR}
program record_bug;
type
TColor = object
R : Byte;
function toDWord : DWord;
end;
function TColor.toDWord : DWord;
begin
r:=4;
toDWord:=5;
end;
procedure Fill(Color: TColor);
begin
Color.toDWord;
if color.r<>4 then
halt(1);
end;
var
c: TColor;
begin
c.r:=1;
Fill(c);
end.