fcl-passrc: useanalyzer: fixed omitting not used hints for properties

This commit is contained in:
mattias 2021-02-13 13:19:56 +00:00
parent 3787087cae
commit 0c50b6a698
2 changed files with 22 additions and 0 deletions

View File

@ -2847,6 +2847,7 @@ begin
begin
// write without read
if (vmExternal in El.VarModifiers)
or (El.ClassType=TPasProperty)
or ((El.Parent is TPasClassType) and TPasClassType(El.Parent).IsExternal) then
exit;
if El.Visibility in [visPrivate,visStrictPrivate] then

View File

@ -114,6 +114,7 @@ type
procedure TestM_Hint_InterfaceUnitVariableUsed;
procedure TestM_Hint_ValueParameterIsAssignedButNeverUsed;
procedure TestM_Hint_LocalVariableIsAssignedButNeverUsed;
procedure TestM_Hint_PropertyIsAssignedButNeverUsed;
procedure TestM_Hint_LocalXYNotUsed;
procedure TestM_Hint_PrivateFieldIsNeverUsed;
procedure TestM_Hint_PrivateFieldIsAssignedButNeverUsed;
@ -1917,6 +1918,26 @@ begin
CheckUseAnalyzerUnexpectedHints;
end;
procedure TTestUseAnalyzer.TestM_Hint_PropertyIsAssignedButNeverUsed;
begin
StartProgram(true);
Add([
'type',
' TObject = class',
' private',
' FSize: word;',
' public',
' property ReadSize: word read FSize;',
' property WriteSize: word write FSize;',
' end;',
'var o: TObject;',
'begin',
' o.WriteSize:=o.ReadSize;',
'']);
AnalyzeProgram;
CheckUseAnalyzerUnexpectedHints;
end;
procedure TTestUseAnalyzer.TestM_Hint_LocalXYNotUsed;
begin
StartProgram(true);