Avoid keeping optimized out node in callcleanupblock.statements or callinitblock.statements

git-svn-id: trunk@49094 -
This commit is contained in:
pierre 2021-03-31 20:53:08 +00:00
parent b5a8164233
commit c8c6e647be

View File

@ -1986,7 +1986,8 @@ implementation
procedure tcallnode.add_init_statement(n:tnode);
var
lastinitstatement : tstatementnode;
lastinitstatement, before_firstpass : tstatementnode;
was_first_statement : boolean;
begin
if not assigned(n) then
exit;
@ -1999,6 +2000,7 @@ implementation
exit;
end;
lastinitstatement:=laststatement(callinitblock);
was_first_statement:=(lastinitstatement=callinitblock.statements);
{ all these nodes must be immediately typechecked, because this routine }
{ can be called from pass_1 (i.e., after typecheck has already run) and }
{ moreover, the entire blocks themselves are also only typechecked in }
@ -2006,7 +2008,10 @@ implementation
{ typecheck pass for simplify purposes (not yet perfect, because the }
{ statementnodes themselves are not typechecked this way) }
addstatement(lastinitstatement,n);
before_firstpass:=lastinitstatement;
firstpass(tnode(lastinitstatement));
if was_first_statement and (lastinitstatement<>before_firstpass) then
callinitblock.statements:=lastinitstatement;
{ Update expectloc for callinitblock }
callinitblock.expectloc:=lastinitstatement.expectloc;
end;
@ -2014,7 +2019,8 @@ implementation
procedure tcallnode.add_done_statement(n:tnode);
var
lastdonestatement : tstatementnode;
lastdonestatement, before_firstpass : tstatementnode;
was_first_statement : boolean;
begin
if not assigned(n) then
exit;
@ -2027,9 +2033,13 @@ implementation
exit;
end;
lastdonestatement:=laststatement(callcleanupblock);
was_first_statement:=(lastdonestatement=callcleanupblock.statements);
{ see comments in add_init_statement }
addstatement(lastdonestatement,n);
before_firstpass:=lastdonestatement;
firstpass(tnode(lastdonestatement));
if was_first_statement and (lastdonestatement<>before_firstpass) then
callcleanupblock.statements:=lastdonestatement;
{ Update expectloc for callcleanupblock }
callcleanupblock.expectloc:=lastdonestatement.expectloc;
end;