mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 08:00:52 +02:00
* don't crash when "return exitvalue" is used in a procedure
git-svn-id: trunk@30177 -
This commit is contained in:
parent
39dbfcc3d5
commit
5b3c511467
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -11912,6 +11912,7 @@ tests/test/tlibrary2.pp svneol=native#text/plain
|
||||
tests/test/tlibrary3.pp svneol=native#text/plain
|
||||
tests/test/tmacbool.pp svneol=native#text/plain
|
||||
tests/test/tmacfunret.pp svneol=native#text/plain
|
||||
tests/test/tmacfunret2.pp svneol=native#text/plain
|
||||
tests/test/tmaclocalprocparam1.pp svneol=native#text/plain
|
||||
tests/test/tmaclocalprocparam1a.pp svneol=native#text/plain
|
||||
tests/test/tmaclocalprocparam2.pp svneol=native#text/plain
|
||||
|
@ -3118,10 +3118,21 @@ implementation
|
||||
_RETURN :
|
||||
begin
|
||||
consume(_RETURN);
|
||||
p1:=nil;
|
||||
if not(token in [_SEMICOLON,_ELSE,_END]) then
|
||||
p1 := cexitnode.create(comp_expr(true,false))
|
||||
else
|
||||
p1 := cexitnode.create(nil);
|
||||
begin
|
||||
p1:=comp_expr(true,false);
|
||||
if not assigned(current_procinfo) or
|
||||
(current_procinfo.procdef.proctypeoption in [potype_constructor,potype_destructor]) or
|
||||
is_void(current_procinfo.procdef.returndef) then
|
||||
begin
|
||||
Message(parser_e_void_function);
|
||||
{ recovery }
|
||||
p1.free;
|
||||
p1:=nil;
|
||||
end;
|
||||
end;
|
||||
p1 := cexitnode.create(p1);
|
||||
end;
|
||||
_INHERITED :
|
||||
begin
|
||||
|
12
tests/test/tmacfunret2.pp
Normal file
12
tests/test/tmacfunret2.pp
Normal file
@ -0,0 +1,12 @@
|
||||
{ %fail }
|
||||
|
||||
{$mode macpas}
|
||||
|
||||
procedure Example;
|
||||
|
||||
begin
|
||||
return false; // compiler catches this, but crashes instead of reporting an error
|
||||
end;
|
||||
|
||||
begin
|
||||
end.
|
Loading…
Reference in New Issue
Block a user