fpc/tests/webtbs/tw24844b.pp
Jonas Maebe 9450407ed5 * when taking the address of a method1 that is specified by subscripting
the result of a objtype.method2 call, ensure that we call method2 with
    objtype as methdpointer rather than the self node of the current routine
    (mantis #24844)

git-svn-id: trunk@27977 -
2014-06-15 17:26:12 +00:00

52 lines
588 B
ObjectPascal

program method_init;
{$mode objfpc}
{.$mode delphi}
Type
{ TObj }
TObj = Class
class var
a: record
b: byte;
end;
procedure Test;
end;
{ TObj }
procedure TObj.Test;
Var
proc : procedure of object;
p : pbyte;
begin
a.b:=5;
p:=@tobj.create.a.b;
if p^<>5 then
halt(1);
end;
procedure UncompilableProc;
Var
proc : procedure of object;
p : pbyte;
begin
tobj.a.b:=6;
p:=@tobj.create.a.b;
if p^<>6 then
halt(2);
end;
begin
WriteLn('Mode: ', {$IFDEF FPC_DELPHI}'delphi'{$ELSE}'objfpc'{$ENDIF});
TObj.Create.Test;
UncompilableProc;
end.