compiler: don't create loadvmtaddrnode for record references, they have no VMT (fixes bug #23130)

git-svn-id: trunk@23417 -
This commit is contained in:
paul 2013-01-17 07:30:00 +00:00
parent 890e91ab8c
commit 4d79a44e4c
4 changed files with 44 additions and 4 deletions

1
.gitattributes vendored
View File

@ -13105,6 +13105,7 @@ tests/webtbs/tw2305.pp svneol=native#text/plain
tests/webtbs/tw2306.pp svneol=native#text/plain
tests/webtbs/tw2307.pp svneol=native#text/plain
tests/webtbs/tw2311.pp svneol=native#text/plain
tests/webtbs/tw23130.pp svneol=native#text/pascal
tests/webtbs/tw23136.pp svneol=native#text/pascal
tests/webtbs/tw2317.pp svneol=native#text/plain
tests/webtbs/tw2318.pp svneol=native#text/plain

View File

@ -168,8 +168,7 @@ implementation
case left.resultdef.typ of
classrefdef :
resultdef:=left.resultdef;
objectdef,
recorddef:
objectdef:
{ access to the classtype while specializing? }
if (df_generic in left.resultdef.defoptions) then
begin

View File

@ -923,7 +923,10 @@ implementation
begin
{ We are calling from the static class method which has no self node }
if assigned(current_procinfo) and current_procinfo.procdef.no_self_node then
p1:=cloadvmtaddrnode.create(ctypenode.create(current_procinfo.procdef.struct))
if st.symtabletype=recordsymtable then
p1:=ctypenode.create(current_procinfo.procdef.struct)
else
p1:=cloadvmtaddrnode.create(ctypenode.create(current_procinfo.procdef.struct))
else
p1:=load_self_node;
{ We are calling a member }
@ -2445,7 +2448,10 @@ implementation
if assigned(current_structdef) and
(((current_structdef<>hdef) and is_owned_by(current_structdef,hdef)) or
(sp_static in srsym.symoptions)) then
p1:=cloadvmtaddrnode.create(ctypenode.create(hdef))
if srsymtable.symtabletype=recordsymtable then
p1:=ctypenode.create(hdef)
else
p1:=cloadvmtaddrnode.create(ctypenode.create(hdef))
else
if assigned(current_procinfo) and current_procinfo.procdef.no_self_node then
p1:=cloadvmtaddrnode.create(ctypenode.create(current_procinfo.procdef.struct))

34
tests/webtbs/tw23130.pp Normal file
View File

@ -0,0 +1,34 @@
program tw23130;
{$MODE DELPHI}
type
TFunction<TArgument, TResult> = function (const arg: TArgument): TResult;
TWrapper = record
class function Z(const arg: Integer): Boolean; static;
class procedure W; static;
end;
TWrapper2 = class
procedure ZZ(f: TFunction<Integer, Boolean>);
end;
class function TWrapper.Z(const arg: Integer): Boolean;
begin
Result := arg < 0;
end;
class procedure TWrapper.W;
begin
with TWrapper2.Create do begin
ZZ(@Z); { Replace with @TWrapper.Z to get rid of the error }
Free;
end;
end;
procedure TWrapper2.ZZ(f: TFunction<Integer, Boolean>);
begin
end;
begin
end.