+ support procvar[] in tp/mac procvar mode if the procvar returns an array type

This commit is contained in:
florian 2023-01-22 16:23:57 +01:00
parent a57e34403c
commit ec28b7586c
2 changed files with 35 additions and 1 deletions
compiler
tests/tbs

View File

@ -2184,7 +2184,7 @@ implementation
begin
consume(_CARET);
{ support tp/mac procvar^ if the procvar returns a
{ support in tp/mac procvar mode procvar^ if the procvar returns a
pointer type }
if ((m_tp_procvar in current_settings.modeswitches) or
(m_mac_procvar in current_settings.modeswitches)) and
@ -2230,6 +2230,17 @@ implementation
_LECKKLAMMER:
begin
{ support in tp/mac procvar mode procvar[] if the procvar returns an
array type }
if ((m_tp_procvar in current_settings.modeswitches) or
(m_mac_procvar in current_settings.modeswitches)) and
(p1.resultdef.typ=procvardef) and
(tprocvardef(p1.resultdef).returndef.typ=arraydef) then
begin
p1:=ccallnode.create_procvar(nil,p1);
typecheckpass(p1);
end;
if is_class_or_interface_or_object(p1.resultdef) or
is_dispinterface(p1.resultdef) or
is_record(p1.resultdef) or

23
tests/tbs/tb0703.pp Normal file
View File

@ -0,0 +1,23 @@
{$mode delphi}
uses
Types;
type
TArrayFunc = function: TIntegerDynArray;
function MyFunc : TIntegerDynArray;
begin
SetLength(Result,1);
Result[0]:=$12345678;
end;
var
f: TArrayFunc;
i: integer;
begin
f := @MyFunc;
i := f[0];
if i<>$12345678 then
halt(1);
end.