* fixed calling static class methods from inside other static class methods

git-svn-id: trunk@12866 -
This commit is contained in:
Jonas Maebe 2009-03-08 12:38:02 +00:00
parent 9a0d4230b9
commit da461c5154
4 changed files with 54 additions and 3 deletions

1
.gitattributes vendored
View File

@ -8746,6 +8746,7 @@ tests/webtbs/tw1223.pp svneol=native#text/plain
tests/webtbs/tw12233.pp svneol=native#text/plain
tests/webtbs/tw12237.pp svneol=native#text/plain
tests/webtbs/tw12242.pp svneol=native#text/plain
tests/webtbs/tw12242a.pp svneol=native#text/plain
tests/webtbs/tw12249.pp svneol=native#text/plain
tests/webtbs/tw12255.pp svneol=native#text/plain
tests/webtbs/tw1228.pp svneol=native#text/plain

View File

@ -2608,7 +2608,8 @@ implementation
begin
{ When this is method the methodpointer must be available }
if (right=nil) and
(procdefinition.owner.symtabletype=ObjectSymtable) then
(procdefinition.owner.symtabletype=ObjectSymtable) and
not([po_staticmethod,po_classmethod] <= procdefinition.procoptions) then
internalerror(200305061);
end;

View File

@ -840,8 +840,13 @@ implementation
aprocdef:=nil;
{ when it is a call to a member we need to load the
methodpointer first }
membercall:=maybe_load_methodpointer(st,p1);
methodpointer first
(except if we are in a static class method)
}
membercall:=
not(assigned(current_procinfo) and
([po_staticmethod,po_classmethod] <= current_procinfo.procdef.procoptions)) and
maybe_load_methodpointer(st,p1);
{ When we are expecting a procvar we also need
to get the address in some cases }

44
tests/webtbs/tw12242a.pp Normal file
View File

@ -0,0 +1,44 @@
{$mode objfpc}
{$static on}
type
tc = class
class procedure a; cdecl; static;
class procedure b; cdecl; static;
procedure c;
end;
var
ok: boolean;
class procedure tc.a; cdecl; static;
begin
writeln('a');
ok:=true;
end;
class procedure tc.b; cdecl; static;
begin
a;
end;
procedure tc.c;
begin
a;
end;
var
c: tc;
begin
ok:=false;
tc.b;
if not ok then
halt(1);
ok:=false;
c:=tc.create;
c.c;
c.free;
if not ok then
halt(2);
end.