* do not throw messages on potentially uninitialized internal symbols, resolves #39744

This commit is contained in:
florian 2022-06-15 23:29:53 +02:00
parent ae346a87a1
commit 98ec81896e
5 changed files with 38 additions and 8 deletions

View File

@ -729,8 +729,10 @@ unit optdfa;
((vo_is_funcret in sym.varoptions) and ((vo_is_funcret in sym.varoptions) and
(current_procinfo.procdef.parast.symtablelevel=sym.owner.symtablelevel) (current_procinfo.procdef.parast.symtablelevel=sym.owner.symtablelevel)
) )
) and not(vo_is_external in sym.varoptions) and ) and
not sym.inparentfpstruct; not(vo_is_external in sym.varoptions) and
not sym.inparentfpstruct and
not(vo_is_internal in sym.varoptions);
end; end;
var var

View File

@ -465,17 +465,17 @@ implementation
end;} end;}
if st.symtabletype=localsymtable then if st.symtabletype=localsymtable then
result:=clocalvarsym.create('$'+capturer_var_name,vs_value,def,[]) result:=clocalvarsym.create('$'+capturer_var_name,vs_value,def,[vo_is_internal])
else else
result:=cstaticvarsym.create('$'+capturer_var_name,vs_value,def,[]); result:=cstaticvarsym.create('$'+capturer_var_name,vs_value,def,[vo_is_internal]);
result.fileinfo:=pd.fileinfo; result.fileinfo:=pd.fileinfo;
st.insertsym(result); st.insertsym(result);
addsymref(result); addsymref(result);
if st.symtabletype=localsymtable then if st.symtabletype=localsymtable then
keepalive:=clocalvarsym.create('$'+capturer_var_name+keepalive_suffix,vs_value,interface_iunknown,[]) keepalive:=clocalvarsym.create('$'+capturer_var_name+keepalive_suffix,vs_value,interface_iunknown,[vo_is_internal])
else else
keepalive:=cstaticvarsym.create('$'+capturer_var_name+keepalive_suffix,vs_value,interface_iunknown,[]); keepalive:=cstaticvarsym.create('$'+capturer_var_name+keepalive_suffix,vs_value,interface_iunknown,[vo_is_internal]);
keepalive.fileinfo:=pd.fileinfo; keepalive.fileinfo:=pd.fileinfo;
st.insertsym(keepalive); st.insertsym(keepalive);
addsymref(keepalive); addsymref(keepalive);

View File

@ -640,7 +640,8 @@ type
{ i8086 'external far' (can only be used in combination with vo_is_external) } { i8086 'external far' (can only be used in combination with vo_is_external) }
vo_is_far, vo_is_far,
{ a static symbol that is referenced from a global function } { a static symbol that is referenced from a global function }
vo_has_global_ref vo_has_global_ref,
vo_is_internal
); );
tvaroptions=set of tvaroption; tvaroptions=set of tvaroption;

View File

@ -3137,7 +3137,8 @@ const
(mask:vo_force_finalize; str:'ForceFinalize'), (mask:vo_force_finalize; str:'ForceFinalize'),
(mask:vo_is_default_var; str:'DefaultIntrinsicVar'), (mask:vo_is_default_var; str:'DefaultIntrinsicVar'),
(mask:vo_is_far; str:'IsFar'), (mask:vo_is_far; str:'IsFar'),
(mask:vo_has_global_ref; str:'HasGlobalRef') (mask:vo_has_global_ref; str:'HasGlobalRef'),
(mask:vo_is_internal; str:'IsInternal')
); );
type type
tvaraccessdesc=record tvaraccessdesc=record

26
tests/webtbs/tw39744.pp Normal file
View File

@ -0,0 +1,26 @@
{ %OPT=-Oodfa -Sew }
program project2;
{$mode delphi}
{$modeswitch anonymousfunctions}
{$modeswitch functionreferences}
type
TFuncRef = reference to function (A, B: Integer): Integer;
function CallFunc(const F: TFuncRef; A, B: Integer): Integer; //overload;
begin
Result := F(A*100, B*100);
end;
function TestRef(A, B, C: Integer): Integer; noinline;
begin
Result := CallFunc(function (A, B: Integer): Integer begin
Result := A + B + C;
end, A, B);
end;
begin
if TestRef(1, 2, 3) <> 303 then
Halt(1);
end.