fcl-passrc: useanalyzer: mark enumvalue parent types

git-svn-id: trunk@35865 -
This commit is contained in:
Mattias Gaertner 2017-04-20 19:14:00 +00:00
parent db6e47a22c
commit 88600b71ef
2 changed files with 19 additions and 1 deletions

View File

@ -610,7 +610,12 @@ begin
else if C.InheritsFrom(TPasExpr) then
UseExpr(TPasExpr(El))
else if C=TPasEnumValue then
MarkElementAsUsed(El)
begin
repeat
MarkElementAsUsed(El);
El:=El.Parent;
until not (El is TPasType);
end
else if C.InheritsFrom(TPasModule) then
// e.g. unitname.identifier -> the module is used by the identifier
else

View File

@ -117,6 +117,7 @@ type
procedure TestWP_PublishedRecordType;
procedure TestWP_PublishedProcType;
procedure TestWP_PublishedProperty;
procedure TestWP_BuiltInFunctions;
end;
implementation
@ -1634,6 +1635,18 @@ begin
AnalyzeWholeProgram;
end;
procedure TTestUseAnalyzer.TestWP_BuiltInFunctions;
begin
StartProgram(false);
Add([
'type',
' {#tordenum_used}TOrdEnum = (ordenum1,ordenum2);',
'begin',
' if ord(ordenum1)=1 then ;',
'']);
AnalyzeWholeProgram;
end;
initialization
RegisterTests([TTestUseAnalyzer]);