* fixed loading the vmt of TP-style objects when it's not at offset zero

(for virtual procvars of object, mantis #17521)

git-svn-id: trunk@16190 -
This commit is contained in:
Jonas Maebe 2010-10-20 12:00:15 +00:00
parent 843ce22187
commit dd8fd7cd4a
3 changed files with 35 additions and 1 deletions

1
.gitattributes vendored
View File

@ -10700,6 +10700,7 @@ tests/webtbs/tw1744.pp svneol=native#text/plain
tests/webtbs/tw17458.pp svneol=native#text/plain
tests/webtbs/tw17493.pp svneol=native#text/plain
tests/webtbs/tw17514.pp svneol=native#text/plain
tests/webtbs/tw17521.pp svneol=native#text/plain
tests/webtbs/tw17546.pp svneol=native#text/plain
tests/webtbs/tw1754c.pp svneol=native#text/plain
tests/webtbs/tw1755.pp svneol=native#text/plain

View File

@ -512,7 +512,7 @@ implementation
if (left.resultdef.typ<>classrefdef) then
begin
{ load vmt pointer }
reference_reset_base(href,hregister,0,sizeof(pint));
reference_reset_base(href,hregister,tobjectdef(left.resultdef).vmt_offset,sizeof(pint));
hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,href,hregister);
end;

33
tests/webtbs/tw17521.pp Normal file
View File

@ -0,0 +1,33 @@
{$mode objfpc}
{$h+}
type tx = object
a,b,c: longint; // remove these => no crash
constructor init;
function v: longint; virtual;
end;
px = ^tx;
constructor tx.init;
begin
end;
function tx.v: longint;
begin
v:=b;
end;
var t : function:longint of object;
p : px;
begin
new( p, init );
p^.a:=3;
p^.b:=4;
p^.c:=5;
p^.v; // ok
t := @p^.v; // sigsegv
if t()<>4 then
halt(1);
end.