* forbid the usage of Result(x) as function call, resolves #14248

git-svn-id: trunk@13492 -
This commit is contained in:
florian 2009-08-06 19:06:23 +00:00
parent 52a16a2b13
commit 6c99746074
3 changed files with 18 additions and 2 deletions

1
.gitattributes vendored
View File

@ -8636,6 +8636,7 @@ tests/webtbf/tw1407.pp svneol=native#text/plain
tests/webtbf/tw14104a.pp svneol=native#text/plain
tests/webtbf/tw14104b.pp svneol=native#text/plain
tests/webtbf/tw14104c.pp svneol=native#text/plain
tests/webtbf/tw14248.pp svneol=native#text/plain
tests/webtbf/tw1432.pp svneol=native#text/plain
tests/webtbf/tw1467.pp svneol=native#text/plain
tests/webtbf/tw1483.pp svneol=native#text/plain

View File

@ -1339,6 +1339,8 @@ implementation
{ Access to funcret or need to call the function? }
if (srsym.typ in [absolutevarsym,localvarsym,paravarsym]) and
(vo_is_funcret in tabstractvarsym(srsym).varoptions) and
{ result(x) is not allowed }
not(vo_is_result in tabstractvarsym(srsym).varoptions) and
(
(token=_LKLAMMER) or
(
@ -1346,8 +1348,7 @@ implementation
(m_tp7 in current_settings.modeswitches) or
(m_delphi in current_settings.modeswitches)
) and
(afterassignment or in_args) and
not(vo_is_result in tabstractvarsym(srsym).varoptions)
(afterassignment or in_args)
)
) then
begin

14
tests/webtbf/tw14248.pp Normal file
View File

@ -0,0 +1,14 @@
{ %fail }
program Project1;
{$mode objfpc}{$H+}
function Foo(a: Integer): Integer;
begin
dec(a);
if a < 0 then exit;
Result := Result(a);
end;
begin
Foo(10);
end.