mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 19:49:12 +02:00
* Handle assigned(x) expressions entirely in first pass by converting them to "x<>nil", indicate that procedure variables should not be called by setting nf_load_procvar flag (which is already used with typeconvnode for exactly the same purpose). This allows to generate better code when assigned(x) is used on right side of assigments. Mantis #24572.
git-svn-id: trunk@25499 -
This commit is contained in:
parent
4ea89d01ea
commit
dac8cbcefc
@ -1017,9 +1017,15 @@ implementation
|
|||||||
if codegenerror then
|
if codegenerror then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
{ tp procvar support }
|
{ tp procvar support. Omit for converted assigned() nodes }
|
||||||
maybe_call_procvar(left,true);
|
if not (nf_load_procvar in flags) then
|
||||||
maybe_call_procvar(right,true);
|
begin
|
||||||
|
maybe_call_procvar(left,true);
|
||||||
|
maybe_call_procvar(right,true);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if not (nodetype in [equaln,unequaln]) then
|
||||||
|
InternalError(2013091601);
|
||||||
|
|
||||||
{ convert array constructors to sets, because there is no other operator
|
{ convert array constructors to sets, because there is no other operator
|
||||||
possible for array constructors }
|
possible for array constructors }
|
||||||
|
@ -579,10 +579,7 @@ implementation
|
|||||||
|
|
||||||
procedure tcginlinenode.second_assigned;
|
procedure tcginlinenode.second_assigned;
|
||||||
begin
|
begin
|
||||||
secondpass(tcallparanode(left).left);
|
internalerror(2013091602);
|
||||||
hlcg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,left.resultdef,OC_NE,0,tcallparanode(left).left.location,current_procinfo.CurrTrueLabel);
|
|
||||||
hlcg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
|
|
||||||
location_reset(location,LOC_JUMP,OS_NO);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Tcginlinenode.second_get_frame;
|
procedure Tcginlinenode.second_get_frame;
|
||||||
|
@ -2783,9 +2783,8 @@ implementation
|
|||||||
tcallparanode(left).get_paratype;
|
tcallparanode(left).get_paratype;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ converting to an add node is tricky because of differences
|
{ Postpone conversion into addnode until firstpass, so targets
|
||||||
in procvar handling between FPC and Delphi handling, so
|
may override first_assigned and insert specific code. }
|
||||||
handle specially }
|
|
||||||
set_varstate(tcallparanode(left).left,vs_read,[vsf_must_be_valid]);
|
set_varstate(tcallparanode(left).left,vs_read,[vsf_must_be_valid]);
|
||||||
resultdef:=pasbool8type;
|
resultdef:=pasbool8type;
|
||||||
end;
|
end;
|
||||||
@ -3983,10 +3982,13 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function tinlinenode.first_assigned: tnode;
|
function tinlinenode.first_assigned: tnode;
|
||||||
begin
|
begin
|
||||||
result:=nil;
|
{ Comparison must not call procvars, indicate that with nf_load_procvar flag }
|
||||||
expectloc := LOC_JUMP;
|
result:=caddnode.create(unequaln,tcallparanode(left).left,cnilnode.create);
|
||||||
|
include(result.flags,nf_load_procvar);
|
||||||
|
tcallparanode(left).left:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,6 +251,7 @@ interface
|
|||||||
|
|
||||||
{ ttypeconvnode, and the first one also treal/ord/pointerconstn }
|
{ ttypeconvnode, and the first one also treal/ord/pointerconstn }
|
||||||
{ second one also for subtractions of u32-u32 implicitly upcasted to s64 }
|
{ second one also for subtractions of u32-u32 implicitly upcasted to s64 }
|
||||||
|
{ last one also used on addnode to inhibit procvar calling }
|
||||||
nf_explicit,
|
nf_explicit,
|
||||||
nf_internal, { no warnings/hints generated }
|
nf_internal, { no warnings/hints generated }
|
||||||
nf_load_procvar,
|
nf_load_procvar,
|
||||||
|
Loading…
Reference in New Issue
Block a user