* don't crash when "return exitvalue" is used in a procedure

git-svn-id: trunk@30177 -
This commit is contained in:
Jonas Maebe 2015-03-13 08:35:26 +00:00
parent 39dbfcc3d5
commit 5b3c511467
3 changed files with 27 additions and 3 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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
View 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.