* ttryfinallynode now inherits from tbinarynode instead of tloopnode, as its

t1 field was always set to tnothingnode

git-svn-id: trunk@40142 -
This commit is contained in:
Jonas Maebe 2018-11-01 13:19:33 +00:00
parent cc44f64920
commit 0cd85d73e4
7 changed files with 17 additions and 52 deletions

View File

@ -44,7 +44,7 @@ interface
ti386tryfinallynode=class(tcgtryfinallynode)
finalizepi: tcgprocinfo;
constructor create(l,r:TNode);override;
constructor create_implicit(l,r,_t1:TNode);override;
constructor create_implicit(l,r:TNode);override;
function pass_1: tnode;override;
function simplify(forinline: boolean): tnode;override;
procedure pass_generate_code;override;
@ -183,9 +183,9 @@ constructor ti386tryfinallynode.create(l, r: TNode);
include(finalizepi.flags,pi_uses_exceptions);
end;
constructor ti386tryfinallynode.create_implicit(l, r, _t1: TNode);
constructor ti386tryfinallynode.create_implicit(l, r: TNode);
begin
inherited create_implicit(l, r, _t1);
inherited create_implicit(l, r);
if (target_info.system<>system_i386_win32) then
exit;

View File

@ -1183,11 +1183,6 @@ implementation
{ finally code only needed to be executed on exception (-> in
if-branch -> fc_inflowcontrol) }
flowcontrol:=[fc_inflowcontrol];
secondpass(t1);
if flowcontrol<>[fc_inflowcontrol] then
CGMessage(cg_e_control_flow_outside_finally);
if codegenerror then
exit;
if (tf_safecall_exceptions in target_info.flags) and
(current_procinfo.procdef.proccalloption=pocall_safecall) then
handle_safecall_exception

View File

@ -189,10 +189,10 @@ interface
end;
ttryexceptnodeclass = class of ttryexceptnode;
ttryfinallynode = class(tloopnode)
ttryfinallynode = class(tbinarynode)
implicitframe : boolean;
constructor create(l,r:tnode);virtual;reintroduce;
constructor create_implicit(l,r,_t1:tnode);virtual;
constructor create_implicit(l,r:tnode);virtual;
function pass_typecheck:tnode;override;
function pass_1 : tnode;override;
function simplify(forinline:boolean): tnode;override;
@ -2299,14 +2299,14 @@ implementation
constructor ttryfinallynode.create(l,r:tnode);
begin
inherited create(tryfinallyn,l,r,nil,nil);
inherited create(tryfinallyn,l,r);
implicitframe:=false;
end;
constructor ttryfinallynode.create_implicit(l,r,_t1:tnode);
constructor ttryfinallynode.create_implicit(l,r:tnode);
begin
inherited create(tryfinallyn,l,r,_t1,nil);
inherited create(tryfinallyn,l,r);
implicitframe:=true;
end;
@ -2323,14 +2323,6 @@ implementation
typecheckpass(right);
// "except block" is "used"? (JM)
set_varstate(right,vs_readwritten,[vsf_must_be_valid]);
{ special finally block only executed when there was an exception }
if assigned(t1) then
begin
typecheckpass(t1);
// "finally block" is "used"? (JM)
set_varstate(t1,vs_readwritten,[vsf_must_be_valid]);
end;
end;
@ -2342,9 +2334,6 @@ implementation
firstpass(right);
if assigned(t1) then
firstpass(t1);
include(current_procinfo.flags,pi_do_call);
{ pi_uses_exceptions is an information for the optimizer and it

View File

@ -196,7 +196,7 @@ implementation
result := foreachnode(procmethod,tcallnode(n).funcretnode,f,arg) or result;
result := foreachnode(procmethod,tnode(tcallnode(n).callcleanupblock),f,arg) or result;
end;
ifn, whilerepeatn, forn, tryexceptn, tryfinallyn:
ifn, whilerepeatn, forn, tryexceptn:
begin
{ not in one statement, won't work because of b- }
result := foreachnode(procmethod,tloopnode(n).t1,f,arg) or result;
@ -293,7 +293,7 @@ implementation
result := foreachnodestatic(procmethod,tcallnode(n).funcretnode,f,arg) or result;
result := foreachnodestatic(procmethod,tnode(tcallnode(n).callcleanupblock),f,arg) or result;
end;
ifn, whilerepeatn, forn, tryexceptn, tryfinallyn:
ifn, whilerepeatn, forn, tryexceptn:
begin
{ not in one statement, won't work because of b- }
result := foreachnodestatic(procmethod,tloopnode(n).t1,f,arg) or result;

View File

@ -43,7 +43,7 @@ type
{$endif Test_Double_checksum}
const
CurrentPPUVersion = 202;
CurrentPPUVersion = 203;
{ unit flags }
uf_init = $000001; { unit has initialization section }

View File

@ -919,10 +919,7 @@ implementation
final_used:=true;
current_filepos:=entrypos;
wrappedbody:=ctryfinallynode.create_implicit(
code,
finalcode,
cnothingnode.create);
wrappedbody:=ctryfinallynode.create_implicit(code,finalcode);
{ afterconstruction must be called after final_asmnode, because it
has to execute after the temps have been finalised in case of a
refcounted class (afterconstruction decreases the refcount

View File

@ -44,7 +44,7 @@ interface
tx64tryfinallynode=class(tcgtryfinallynode)
finalizepi: tcgprocinfo;
constructor create(l,r:TNode);override;
constructor create_implicit(l,r,_t1:TNode);override;
constructor create_implicit(l,r:TNode);override;
function simplify(forinline: boolean): tnode;override;
procedure pass_generate_code;override;
end;
@ -176,9 +176,9 @@ constructor tx64tryfinallynode.create(l, r: TNode);
end;
end;
constructor tx64tryfinallynode.create_implicit(l, r, _t1: TNode);
constructor tx64tryfinallynode.create_implicit(l, r: TNode);
begin
inherited create_implicit(l, r, _t1);
inherited create_implicit(l, r);
if (target_info.system=system_x86_64_win64) then
begin
if df_generic in current_procinfo.procdef.defoptions then
@ -254,8 +254,8 @@ procedure tx64tryfinallynode.pass_generate_code;
{ Do not generate a frame that catches exceptions if the only action
would be reraising it. Doing so is extremely inefficient with SEH
(in contrast with setjmp/longjmp exception handling) }
catch_frame:=implicitframe and ((not has_no_code(t1)) or
(current_procinfo.procdef.proccalloption=pocall_safecall));
catch_frame:=implicitframe and
(current_procinfo.procdef.proccalloption=pocall_safecall);
oldflowcontrol:=flowcontrol;
flowcontrol:=[fc_inflowcontrol];
@ -458,28 +458,12 @@ procedure tx64tryexceptnode.pass_generate_code;
inc(onnodecount.value);
hnode:=tonnode(hnode).left;
end;
{ add 'else' node to the filter list, too }
if assigned(t1) then
begin
hlist.concat(tai_const.create_32bit(-1));
hlist.concat(tai_const.create_rva_sym(lastonlabel));
inc(onnodecount.value);
end;
{ now move filter table to permanent list all at once }
current_procinfo.aktlocaldata.concatlist(hlist);
hlist.free;
end;
cg.a_label(current_asmdata.CurrAsmList,lastonlabel);
if assigned(t1) then
begin
{ here we don't have to reset flowcontrol }
{ the default and on flowcontrols are handled equal }
secondpass(t1);
cg.g_call(current_asmdata.CurrAsmList,'FPC_DONEEXCEPTION');
if (flowcontrol*[fc_exit,fc_break,fc_continue]<>[]) then
cg.a_jmp_always(current_asmdata.CurrAsmList,endexceptlabel);
end;
exceptflowcontrol:=flowcontrol;
if fc_exit in exceptflowcontrol then