* enable converting procedure callnodes with only default parameters into

procvars in tp/delphi mode (mantis #11771)

git-svn-id: trunk@13400 -
This commit is contained in:
Jonas Maebe 2009-07-17 10:29:56 +00:00
parent ee49e8acb6
commit 754696d1f5
4 changed files with 74 additions and 1 deletions

1
.gitattributes vendored
View File

@ -9058,6 +9058,7 @@ tests/webtbs/tw11638.pp svneol=native#text/plain
tests/webtbs/tw11711.pp svneol=native#text/plain
tests/webtbs/tw11762.pp svneol=native#text/plain
tests/webtbs/tw11763.pp svneol=native#text/plain
tests/webtbs/tw11771.pp svneol=native#text/plain
tests/webtbs/tw11786.pp svneol=native#text/plain
tests/webtbs/tw11791.pp svneol=native#text/plain
tests/webtbs/tw1181.pp svneol=native#text/plain

View File

@ -144,6 +144,7 @@ interface
function docompare(p: tnode): boolean; override;
procedure printnodedata(var t:text);override;
function para_count:longint;
function required_para_count:longint;
{ checks if there are any parameters which end up at the stack, i.e.
which have LOC_REFERENCE and set pi_has_stackparameter if this applies }
procedure check_stack_parameters;
@ -1219,6 +1220,23 @@ implementation
end;
function tcallnode.required_para_count: longint;
var
ppn : tcallparanode;
begin
result:=0;
ppn:=tcallparanode(left);
while assigned(ppn) do
begin
if not(assigned(ppn.parasym) and
((vo_is_hidden_para in ppn.parasym.varoptions) or
assigned(ppn.parasym.defaultconstsym))) then
inc(result);
ppn:=tcallparanode(ppn.right);
end;
end;
function tcallnode.is_simple_para_load(p:tnode; may_be_in_reg: boolean):boolean;
var
hp : tnode;

View File

@ -1716,7 +1716,7 @@ implementation
a procvar. Because isconvertable cannot check for procedures we
use an extra check for them.}
if (left.nodetype=calln) and
(tcallnode(left).para_count=0) and
(tcallnode(left).required_para_count=0) and
(resultdef.typ=procvardef) and
(
(m_tp_procvar in current_settings.modeswitches) or

54
tests/webtbs/tw11771.pp Normal file
View File

@ -0,0 +1,54 @@
{$MODE delphi}
unit tw11771;
interface
type
TEvent = procedure(A : TObject) of object;
TTest = class
private
FProc: TEvent;
procedure Proc1(A : TObject);
procedure Proc2(A : TObject = nil);
public
constructor Create;
procedure B(A : TEvent);
property A : TEvent read FProc write FProc;
end;
implementation
constructor TTest.Create;
begin
// FProc := Proc1;
// FProc := Proc2;
A := Proc1;
A := Proc2;
// B(Proc1);
B(Proc2);
end;
procedure ttest.Proc1(A : TObject);
begin
end;
procedure ttest.Proc2(A : TObject = nil);
begin
end;
procedure ttest.B(A : TEvent);
begin
end;
end.