From 43b5dbf6136f053f082c975c8e8d5cb1610ea750 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Fri, 19 Jul 2019 15:55:28 +0000 Subject: [PATCH] * fix for Mantis #23071: also store local symtable in the PPU if the procdef is generic as we need it to resolve genericdefs to nested types git-svn-id: trunk@42459 - --- .gitattributes | 2 ++ compiler/symdef.pas | 41 +++++++++++++++++++++++++---------------- tests/webtbs/tw23071.pp | 10 ++++++++++ tests/webtbs/uw23071.pp | 20 ++++++++++++++++++++ 4 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 tests/webtbs/tw23071.pp create mode 100644 tests/webtbs/uw23071.pp diff --git a/.gitattributes b/.gitattributes index 9e9ed0005b..5758d459ad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15980,6 +15980,7 @@ tests/webtbs/tw2300.pp svneol=native#text/plain tests/webtbs/tw2305.pp svneol=native#text/plain tests/webtbs/tw2306.pp svneol=native#text/plain tests/webtbs/tw2307.pp svneol=native#text/plain +tests/webtbs/tw23071.pp svneol=native#text/pascal tests/webtbs/tw23109.pp svneol=native#text/plain tests/webtbs/tw2311.pp svneol=native#text/plain tests/webtbs/tw23130.pp svneol=native#text/pascal @@ -17224,6 +17225,7 @@ tests/webtbs/uw2266b.pas svneol=native#text/plain tests/webtbs/uw2269.inc svneol=native#text/plain tests/webtbs/uw22741a.pp svneol=native#text/plain tests/webtbs/uw22741b.pp svneol=native#text/plain +tests/webtbs/uw23071.pp svneol=native#text/pascal tests/webtbs/uw23204.pp svneol=native#text/plain tests/webtbs/uw2364.pp svneol=native#text/plain tests/webtbs/uw25054a.pp svneol=native#text/pascal diff --git a/compiler/symdef.pas b/compiler/symdef.pas index c564f7c74b..8d0a4812aa 100644 --- a/compiler/symdef.pas +++ b/compiler/symdef.pas @@ -773,6 +773,8 @@ interface procdef has been handled } implprocdefinfo : pimplprocdefinfo; + function store_localst:boolean; + function GetResultName: PShortString; procedure SetResultName(AValue: PShortString); function GetParentFPStruct: tsym; @@ -5716,6 +5718,13 @@ implementation TPROCDEF ***************************************************************************} + + function tprocdef.store_localst: boolean; + begin + result:=has_inlininginfo or (df_generic in defoptions); + end; + + function tprocdef.GetResultName: PShortString; begin if not assigned(implprocdefinfo) then @@ -6039,7 +6048,7 @@ implementation parast:=tparasymtable.create(self,level); tparasymtable(parast).ppuload(ppufile); { load local symtable } - if has_inlininginfo then + if store_localst then begin localst:=tlocalsymtable.create(self,level); tlocalsymtable(localst).ppuload(ppufile); @@ -6221,7 +6230,7 @@ implementation { save localsymtable for inline procedures or when local browser info is requested, this has no influence on the crc } - if has_inlininginfo then + if store_localst and not ppufile.crc_only then begin oldintfcrc:=ppufile.do_crc; ppufile.do_crc:=false; @@ -6512,16 +6521,16 @@ implementation begin inherited buildderefimpl; + { Localst is not available for main/unit init } + if store_localst and assigned(localst) then + begin + tlocalsymtable(localst).buildderef; + tlocalsymtable(localst).buildderefimpl; + end; + { inline tree } if has_inlininginfo then begin - { Localst is not available for main/unit init } - if assigned(localst) then - begin - tlocalsymtable(localst).buildderef; - tlocalsymtable(localst).buildderefimpl; - end; - funcretsymderef.build(funcretsym); inlininginfo^.code.buildderefimpl; end; @@ -6546,16 +6555,16 @@ implementation if assigned(inlininginfo) then has_inlininginfo:=true; + { Locals } + if store_localst and assigned(localst) then + begin + tlocalsymtable(localst).deref(false); + tlocalsymtable(localst).derefimpl(false); + end; + { Inline } if has_inlininginfo then begin - { Locals } - if assigned(localst) then - begin - tlocalsymtable(localst).deref(false); - tlocalsymtable(localst).derefimpl(false); - end; - inlininginfo^.code.derefimpl; { funcretsym, this is always located in the localst } funcretsym:=tsym(funcretsymderef.resolve); diff --git a/tests/webtbs/tw23071.pp b/tests/webtbs/tw23071.pp new file mode 100644 index 0000000000..35196f75d3 --- /dev/null +++ b/tests/webtbs/tw23071.pp @@ -0,0 +1,10 @@ +{ %NORUN } +{ %RECOMPILE } + +{$MODE DELPHI} + +uses uw23071; + +begin + TWrapper.Z; +end. diff --git a/tests/webtbs/uw23071.pp b/tests/webtbs/uw23071.pp new file mode 100644 index 0000000000..14db9ffc3f --- /dev/null +++ b/tests/webtbs/uw23071.pp @@ -0,0 +1,20 @@ +unit uw23071; + +{$MODE DELPHI} + +interface + +type + TWrapper = record + class procedure Z; static; + end; + +implementation + +class procedure TWrapper.Z; +type + TLocalInteger = Integer; +begin +end; + +end.