mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 20:09:20 +02:00
* remove statements with only a nothing node when they are the only children of a block
git-svn-id: trunk@29628 -
This commit is contained in:
parent
d6bfb29313
commit
7b7aa8d542
@ -540,19 +540,31 @@ implementation
|
|||||||
{ main program body, and those nodes should always be blocknodes }
|
{ main program body, and those nodes should always be blocknodes }
|
||||||
{ since that's what the compiler expects elsewhere. }
|
{ since that's what the compiler expects elsewhere. }
|
||||||
|
|
||||||
{ if the current block contains only one statement, and }
|
|
||||||
{ this one statement only contains another block, replace }
|
|
||||||
{ this block with that other block. }
|
|
||||||
if assigned(left) and
|
if assigned(left) and
|
||||||
not assigned(tstatementnode(left).right) and
|
not assigned(tstatementnode(left).right) then
|
||||||
(tstatementnode(left).left.nodetype = blockn) then
|
|
||||||
begin
|
begin
|
||||||
|
case tstatementnode(left).left.nodetype of
|
||||||
|
blockn:
|
||||||
|
begin
|
||||||
|
{ if the current block contains only one statement, and
|
||||||
|
this one statement only contains another block, replace
|
||||||
|
this block with that other block. }
|
||||||
result:=tstatementnode(left).left;
|
result:=tstatementnode(left).left;
|
||||||
tstatementnode(left).left:=nil;
|
tstatementnode(left).left:=nil;
|
||||||
{ make sure the nf_block_with_exit flag is safeguarded }
|
{ make sure the nf_block_with_exit flag is safeguarded }
|
||||||
result.flags:=result.flags+(flags*[nf_block_with_exit,nf_usercode_entry]);
|
result.flags:=result.flags+(flags*[nf_block_with_exit,nf_usercode_entry]);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
nothingn:
|
||||||
|
begin
|
||||||
|
{ if the block contains only a statement with a nothing node,
|
||||||
|
get rid of the statement }
|
||||||
|
left.Free;
|
||||||
|
left:=nil;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user