+ patch to support assigning class procedures to procedure variables by Ondrej Pokorny, resolves #30936

+ additional tests

git-svn-id: trunk@34909 -
This commit is contained in:
florian 2016-11-17 19:40:42 +00:00
parent 4ddbb7cd26
commit 67570a6262
6 changed files with 135 additions and 1 deletions

4
.gitattributes vendored
View File

@ -15255,6 +15255,10 @@ tests/webtbs/tw3083.pp svneol=native#text/plain
tests/webtbs/tw30889.pp svneol=native#text/pascal
tests/webtbs/tw30923.pp svneol=native#text/pascal
tests/webtbs/tw3093.pp svneol=native#text/plain
tests/webtbs/tw30936.pp svneol=native#text/pascal
tests/webtbs/tw30936a.pp svneol=native#text/pascal
tests/webtbs/tw30936b.pp svneol=native#text/pascal
tests/webtbs/tw30936c.pp svneol=native#text/pascal
tests/webtbs/tw3101.pp svneol=native#text/plain
tests/webtbs/tw3104.pp svneol=native#text/plain
tests/webtbs/tw3109.pp svneol=native#text/plain

View File

@ -6408,7 +6408,7 @@ implementation
function tprocvardef.is_addressonly:boolean;
begin
result:=(not(po_methodpointer in procoptions) and
result:=((not(po_methodpointer in procoptions) or (po_staticmethod in procoptions)) and
not(po_is_block in procoptions) and
not is_nested_pd(self)) or
(po_addressonly in procoptions);

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

@ -0,0 +1,33 @@
program StaticClassProc;
{$MODE OBJFPC}
type
TTest = class
public type
TProcedure = procedure;
private
class procedure MyProc; static;
public
constructor Create;
end;
{ TTest }
constructor TTest.Create;
var
aProc: TProcedure;
begin
aProc := @MyProc;
aProc;
end;
class procedure TTest.MyProc;
begin
Writeln('OK');
end;
begin
TTest.Create;
end.

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

@ -0,0 +1,33 @@
program StaticClassProc;
{$MODE DELPHI}
type
TTest = class
public type
TProcedure = procedure;
private
class procedure MyProc; static;
public
constructor Create;
end;
{ TTest }
constructor TTest.Create;
var
aProc: TProcedure;
begin
aProc := MyProc;
aProc;
end;
class procedure TTest.MyProc;
begin
Writeln('OK');
end;
begin
TTest.Create;
end.

32
tests/webtbs/tw30936b.pp Normal file
View File

@ -0,0 +1,32 @@
program StaticClassProc;
{$MODE OBJFPC}
type
TTest = class
public type
TProcedure = procedure;
private
class procedure MyProc; static;
public
constructor Create;
end;
{ TTest }
constructor TTest.Create;
begin
end;
class procedure TTest.MyProc;
begin
Writeln('OK');
end;
var
aProc: TProcedure;
begin
aProc := @TTest.MyProc;
aProc;
end.

32
tests/webtbs/tw30936c.pp Normal file
View File

@ -0,0 +1,32 @@
program StaticClassProc;
{$MODE DELPHI}
type
TTest = class
public type
TProcedure = procedure;
private
class procedure MyProc; static;
public
constructor Create;
end;
{ TTest }
constructor TTest.Create;
begin
end;
class procedure TTest.MyProc;
begin
Writeln('OK');
end;
var
aProc: TProcedure;
begin
aProc := TTest.MyProc;
aProc;
end.