From b3465a021caabe077758557280abdf72a700ece0 Mon Sep 17 00:00:00 2001 From: Mattias Gaertner Date: Mon, 26 Aug 2019 12:53:50 +0000 Subject: [PATCH] fcl-passrc: useanalyzer: wpo generic git-svn-id: trunk@42827 - --- packages/fcl-passrc/src/pasresolver.pp | 7 +++++- packages/fcl-passrc/src/pasuseanalyzer.pas | 29 +++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/fcl-passrc/src/pasresolver.pp b/packages/fcl-passrc/src/pasresolver.pp index fdb1f433df..40ee4e2465 100644 --- a/packages/fcl-passrc/src/pasresolver.pp +++ b/packages/fcl-passrc/src/pasresolver.pp @@ -26571,8 +26571,13 @@ begin inc(Result); end else if SrcType.ClassType=TPasSpecializeType then + begin // specialize -> skip - SrcType:=TPasSpecializeType(SrcType).DestType + if SrcType.CustomData is TPasSpecializeTypeData then + SrcType:=TPasSpecializeTypeData(SrcType.CustomData).SpecializedType + else + SrcType:=TPasSpecializeType(SrcType).DestType; + end else if SrcType.ClassType=TPasClassType then begin ClassEl:=TPasClassType(SrcType); diff --git a/packages/fcl-passrc/src/pasuseanalyzer.pas b/packages/fcl-passrc/src/pasuseanalyzer.pas index d97c2a71a2..f7534242d4 100644 --- a/packages/fcl-passrc/src/pasuseanalyzer.pas +++ b/packages/fcl-passrc/src/pasuseanalyzer.pas @@ -1010,14 +1010,34 @@ begin end; function TPasAnalyzer.CanSkipGenericType(El: TPasGenericType): boolean; + + procedure RaiseHalfSpecialized; + var + GenScope: TPasGenericScope; + Item: TPSSpecializedItem; + begin + if (El.GenericTemplateTypes<>nil) and (El.GenericTemplateTypes.Count>0) then + RaiseNotSupported(20190817151437,El); + if not (El.CustomData is TPasGenericScope) then + RaiseNotSupported(20190826141320,El,GetObjName(El.CustomData)); + GenScope:=TPasGenericScope(El.CustomData); + Item:=GenScope.SpecializedItem; + if Item=nil then + RaiseNotSupported(20190826141352,El); + if Item.SpecializedType=nil then + RaiseNotSupported(20190826141516,El); + if Item.FirstSpecialize=nil then + RaiseNotSupported(20190826141649,El); + RaiseNotSupported(20190826141540,El,'SpecializedAt:'+GetObjPath(Item.FirstSpecialize)+' '+Resolver.GetElementSourcePosStr(Item.FirstSpecialize)); + end; + begin Result:=false; if ScopeModule=nil then begin // analyze whole program - // -> should only reach fully specialized types if not Resolver.IsFullySpecialized(El) then - RaiseNotSupported(20190817151437,El); + RaiseHalfSpecialized; end else begin @@ -2058,11 +2078,11 @@ var aClass: TPasClassType; begin FirstTime:=true; - if CanSkipGenericType(El) then exit; case Mode of paumAllExports: exit; paumAllPasUsable: begin + if CanSkipGenericType(El) then exit; if MarkElementAsUsed(El) then ElementVisited(El,Mode) else @@ -2075,7 +2095,10 @@ begin end; end; paumElement: + begin + if CanSkipGenericType(El) then exit; if not MarkElementAsUsed(El) then exit; + end else RaiseInconsistency(20170414152143,IntToStr(ord(Mode))); end;