mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 01:29:29 +02:00
compiler: load methodpointer for static class methods - fixes internal error 200305061 when some class member is called inside the class static method + test
git-svn-id: trunk@14571 -
This commit is contained in:
parent
3f17af3437
commit
67ae263dd9
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -9220,6 +9220,7 @@ tests/test/tset6.pp svneol=native#text/plain
|
||||
tests/test/tset7.pp svneol=native#text/plain
|
||||
tests/test/tsetsize.pp svneol=native#text/plain
|
||||
tests/test/tstack.pp svneol=native#text/plain
|
||||
tests/test/tstatic1.pp svneol=native#text/pascal
|
||||
tests/test/tstprocv.pp svneol=native#text/plain
|
||||
tests/test/tstring1.pp svneol=native#text/plain
|
||||
tests/test/tstring10.pp svneol=native#text/plain
|
||||
|
@ -845,7 +845,11 @@ implementation
|
||||
end;
|
||||
ObjectSymtable :
|
||||
begin
|
||||
p1:=load_self_node;
|
||||
if (assigned(current_procinfo) and ([po_staticmethod,po_classmethod] <= current_procinfo.procdef.procoptions)) then
|
||||
{ We are calling from the static class method which has no self node }
|
||||
p1 := cloadvmtaddrnode.create(ctypenode.create(current_procinfo.procdef._class))
|
||||
else
|
||||
p1:=load_self_node;
|
||||
{ We are calling a member }
|
||||
maybe_load_methodpointer:=true;
|
||||
end;
|
||||
@ -871,12 +875,8 @@ implementation
|
||||
|
||||
{ when it is a call to a member we need to load the
|
||||
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);
|
||||
membercall:=maybe_load_methodpointer(st,p1);
|
||||
|
||||
{ When we are expecting a procvar we also need
|
||||
to get the address in some cases }
|
||||
|
30
tests/test/tstatic1.pp
Normal file
30
tests/test/tstatic1.pp
Normal file
@ -0,0 +1,30 @@
|
||||
program tstatic1;
|
||||
{$APPTYPE console}
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}{$H+}
|
||||
{$endif}
|
||||
|
||||
type
|
||||
TSomeClass = class
|
||||
public
|
||||
class procedure SomeClassMethod(A: Integer);
|
||||
class procedure SomeStaticMethod(A: Integer); static;
|
||||
end;
|
||||
|
||||
{ TSomeClass }
|
||||
|
||||
class procedure TSomeClass.SomeClassMethod(A: Integer);
|
||||
begin
|
||||
WriteLn('TSomeClass.SomeClassMethod: ', A);
|
||||
end;
|
||||
|
||||
// for now fpc requires 'static' modifiers also in the class implementation
|
||||
class procedure TSomeClass.SomeStaticMethod(A: Integer); {$ifdef fpc} static; {$endif}
|
||||
begin
|
||||
WriteLn('TSomeClass.SomeStaticMethod: ', A);
|
||||
SomeClassMethod(A + 1);
|
||||
end;
|
||||
|
||||
begin
|
||||
TSomeClass.SomeStaticMethod(1);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user