mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 21:28:03 +02:00
* forbid the usage of Result(x) as function call, resolves #14248
git-svn-id: trunk@13492 -
This commit is contained in:
parent
52a16a2b13
commit
6c99746074
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||
|
@ -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
14
tests/webtbf/tw14248.pp
Normal 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.
|
Loading…
Reference in New Issue
Block a user