From c623824374e7e17129e6931f9b5863f72ce73d9e Mon Sep 17 00:00:00 2001 From: svenbarth Date: Fri, 11 Apr 2014 16:13:44 +0000 Subject: [PATCH] Fix for Mantis #25605. symtable.pas, search_objectpascal_helper: * handle more symbol types than just properties and methods; afterall helpers can have types, static variables and constants as well + added test git-svn-id: trunk@27534 - --- .gitattributes | 1 + compiler/symtable.pas | 59 +++++++++++++++++++++++++---------------- tests/webtbs/tw25605.pp | 18 +++++++++++++ 3 files changed, 55 insertions(+), 23 deletions(-) create mode 100644 tests/webtbs/tw25605.pp diff --git a/.gitattributes b/.gitattributes index c7159858bd..4bcfd43c6a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13900,6 +13900,7 @@ tests/webtbs/tw25551.pp svneol=native#text/plain tests/webtbs/tw25598.pp svneol=native#text/plain tests/webtbs/tw25600.pp svneol=native#text/pascal tests/webtbs/tw25603.pp svneol=native#text/pascal +tests/webtbs/tw25605.pp svneol=native#text/pascal tests/webtbs/tw2561.pp svneol=native#text/plain tests/webtbs/tw25610.pp -text svneol=native#text/plain tests/webtbs/tw25685.pp svneol=native#text/pascal diff --git a/compiler/symtable.pas b/compiler/symtable.pas index b904e355a9..6affa3b1aa 100644 --- a/compiler/symtable.pas +++ b/compiler/symtable.pas @@ -3195,29 +3195,42 @@ implementation if srsym<>nil then begin - if srsym.typ=propertysym then - begin - result:=true; - exit; - end; - for i:=0 to tprocsym(srsym).procdeflist.count-1 do - begin - pdef:=tprocdef(tprocsym(srsym).procdeflist[i]); - if not is_visible_for_object(pdef.owner,pdef.visibility,contextclassh) then - continue; - { we need to know if a procedure references symbols - in the static symtable, because then it can't be - inlined from outside this unit } - if assigned(current_procinfo) and - (srsym.owner.symtabletype=staticsymtable) then - include(current_procinfo.flags,pi_uses_static_symtable); - { the first found method wins } - srsym:=tprocdef(tprocsym(srsym).procdeflist[i]).procsym; - srsymtable:=srsym.owner; - addsymref(srsym); - result:=true; - exit; - end; + case srsym.typ of + procsym: + begin + for i:=0 to tprocsym(srsym).procdeflist.count-1 do + begin + pdef:=tprocdef(tprocsym(srsym).procdeflist[i]); + if not is_visible_for_object(pdef.owner,pdef.visibility,contextclassh) then + continue; + { we need to know if a procedure references symbols + in the static symtable, because then it can't be + inlined from outside this unit } + if assigned(current_procinfo) and + (srsym.owner.symtabletype=staticsymtable) then + include(current_procinfo.flags,pi_uses_static_symtable); + { the first found method wins } + srsym:=tprocdef(tprocsym(srsym).procdeflist[i]).procsym; + srsymtable:=srsym.owner; + addsymref(srsym); + result:=true; + exit; + end; + end; + typesym, + fieldvarsym, + constsym, + enumsym, + undefinedsym, + propertysym: + begin + addsymref(srsym); + result:=true; + exit; + end; + else + internalerror(2014041101); + end; end; { try the helper parent if available } diff --git a/tests/webtbs/tw25605.pp b/tests/webtbs/tw25605.pp new file mode 100644 index 0000000000..573e688e08 --- /dev/null +++ b/tests/webtbs/tw25605.pp @@ -0,0 +1,18 @@ +{ %NORUN } + +program tw25605; // Fatal: Compilation aborted + +{$MODE DELPHI} +{$modeswitch typehelpers} + +type + TValueInt32Helper = record helper for Int32 + const + C: Int32 = 0; + end; + +var + I: Int32; +begin + I := Int32.C; +end.