diff --git a/.gitattributes b/.gitattributes index 363ad12405..54147e0c12 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/compiler/ncal.pas b/compiler/ncal.pas index eeb6e26865..51d18209d5 100644 --- a/compiler/ncal.pas +++ b/compiler/ncal.pas @@ -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 diff --git a/tests/webtbs/tw21177.pp b/tests/webtbs/tw21177.pp new file mode 100644 index 0000000000..9f988a75b0 --- /dev/null +++ b/tests/webtbs/tw21177.pp @@ -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.