* fix finally block getting unconditionally removed if try-block is empty

(hasnocode(nil) always returns true). Regression from r48174

git-svn-id: trunk@49305 -
This commit is contained in:
Jonas Maebe 2021-05-01 09:28:58 +00:00
parent 5cde6facdb
commit 9977889f4a
3 changed files with 21 additions and 2 deletions

1
.gitattributes vendored
View File

@ -18839,6 +18839,7 @@ tests/webtbs/tw38718.pp svneol=native#text/pascal
tests/webtbs/tw38733.pp svneol=native#text/pascal
tests/webtbs/tw38766.pp svneol=native#text/plain
tests/webtbs/tw38802.pp svneol=native#text/pascal
tests/webtbs/tw38833.pp svneol=native#text/plain
tests/webtbs/tw3893.pp svneol=native#text/plain
tests/webtbs/tw3898.pp svneol=native#text/plain
tests/webtbs/tw3899.pp svneol=native#text/plain

View File

@ -2734,10 +2734,10 @@ implementation
begin
result:=right;
right:=nil;
end;
end
{ if the finally block contains no code, we can kill
it and just return the try part }
if has_no_code(right) and not(assigned(third)) and not(implicitframe) then
else if has_no_code(right) and not(assigned(third)) and not(implicitframe) then
begin
result:=left;
left:=nil;

18
tests/webtbs/tw38833.pp Normal file
View File

@ -0,0 +1,18 @@
program EmptyTryFinally1;
{$mode delphi}
{$apptype console}
var
finallyrun: boolean;
begin
finallyrun:=false;
try
// Empty try statement block
finally
WriteLn('I should actually visible . . .'); // but I'm not
finallyrun:=true;
end;
if not finallyrun then
halt(1);
end.