mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-09-23 14:29:05 +02:00
fcl-passrc: fixed marking array argument element passed as arg as read
This commit is contained in:
parent
3b7fc512d1
commit
516a47174c
@ -9906,9 +9906,10 @@ begin
|
||||
pekArrayParams:
|
||||
begin
|
||||
ComputeElement(Params.Value,ValueResolved,[]);
|
||||
if IsDynArray(ValueResolved.LoTypeEl,false) then
|
||||
// an element of a dynamic array is independent of the array variable
|
||||
// an element of an open array depends on the argument
|
||||
if IsDynArray(ValueResolved.LoTypeEl,false)
|
||||
or (ValueResolved.BaseType=btPointer) then
|
||||
// when accessing an element of a dynamic array the array is read
|
||||
AccessExpr(Params.Value,rraRead)
|
||||
else
|
||||
AccessExpr(Params.Value,Access);
|
||||
// Note: an element of an open or static array or a string is connected to the variable
|
||||
|
@ -102,6 +102,7 @@ type
|
||||
procedure TestM_Hint_OutParam_No_AssignedButNeverUsed;
|
||||
procedure TestM_Hint_ArgPassed_No_ParameterNotUsed;
|
||||
procedure TestM_Hint_ArrayArg_No_ParameterNotUsed;
|
||||
procedure TestM_Hint_ArrayArg_No_ParameterNotUsed2;
|
||||
procedure TestM_Hint_InheritedWithoutParams;
|
||||
procedure TestM_Hint_LocalVariableNotUsed;
|
||||
procedure TestM_HintsOff_LocalVariableNotUsed;
|
||||
@ -1620,6 +1621,26 @@ begin
|
||||
CheckUseAnalyzerUnexpectedHints;
|
||||
end;
|
||||
|
||||
procedure TTestUseAnalyzer.TestM_Hint_ArrayArg_No_ParameterNotUsed2;
|
||||
begin
|
||||
StartProgram(false);
|
||||
Add([
|
||||
'type {#Tarr_used}TArr = array of boolean;',
|
||||
'procedure {#Run_used}Run({#b_used}b: boolean);',
|
||||
'begin',
|
||||
' if b then ;',
|
||||
'end;',
|
||||
'procedure {#Fly_used}Fly({#a_used}a: TArr);',
|
||||
'begin',
|
||||
' Run(a[1]);',
|
||||
'end;',
|
||||
'begin',
|
||||
' Fly(nil);',
|
||||
'']);
|
||||
AnalyzeProgram;
|
||||
CheckUseAnalyzerUnexpectedHints;
|
||||
end;
|
||||
|
||||
procedure TTestUseAnalyzer.TestM_Hint_InheritedWithoutParams;
|
||||
begin
|
||||
StartProgram(false);
|
||||
|
Loading…
Reference in New Issue
Block a user