From 9ea38f45778f77c908749eeab5f573daa3d2e204 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Tue, 24 Nov 2015 16:04:19 +0000 Subject: [PATCH] * support static fields in nested types in records, by always including support for nested types when generating an access to a static fied; we also always do that when generating the mangled name of a static field declaration in symcreat.make_field_static() (mantis #29030) git-svn-id: trunk@32517 - --- .gitattributes | 1 + compiler/nutils.pas | 9 +++------ compiler/pexpr.pas | 6 +++--- tests/webtbs/tw29030.pp | 19 +++++++++++++++++++ 4 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 tests/webtbs/tw29030.pp diff --git a/.gitattributes b/.gitattributes index 46ff0005f2..cb03d57635 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14875,6 +14875,7 @@ tests/webtbs/tw2899.pp svneol=native#text/plain tests/webtbs/tw29010a.pp svneol=native#text/plain tests/webtbs/tw29010b.pp svneol=native#text/plain tests/webtbs/tw29010c.pp svneol=native#text/plain +tests/webtbs/tw29030.pp svneol=native#text/plain tests/webtbs/tw2904.pp svneol=native#text/plain tests/webtbs/tw29040.pp svneol=native#text/plain tests/webtbs/tw29053.pp svneol=native#text/pascal diff --git a/compiler/nutils.pas b/compiler/nutils.pas index 297aaf19b5..b565eea4da 100644 --- a/compiler/nutils.pas +++ b/compiler/nutils.pas @@ -104,7 +104,7 @@ interface { checks whether sym is a static field and if so, translates the access to the appropriate node tree } - function handle_staticfield_access(sym: tsym; nested: boolean; var p1: tnode): boolean; + function handle_staticfield_access(sym: tsym; var p1: tnode): boolean; { returns true if n is an array element access of a bitpacked array with elements of the which the vitsize mod 8 <> 0, or if is a field access @@ -1181,7 +1181,7 @@ implementation end; - function handle_staticfield_access(sym: tsym; nested: boolean; var p1: tnode): boolean; + function handle_staticfield_access(sym: tsym; var p1: tnode): boolean; function handle_generic_staticfield_access:boolean; var @@ -1228,10 +1228,7 @@ implementation result:=true; if handle_generic_staticfield_access then exit; - if not nested then - static_name:=lower(sym.owner.name^)+'_'+sym.name - else - static_name:=lower(generate_nested_name(sym.owner,'_'))+'_'+sym.name; + static_name:=lower(generate_nested_name(sym.owner,'_'))+'_'+sym.name; if sym.owner.defowner.typ=objectdef then searchsym_in_class(tobjectdef(sym.owner.defowner),tobjectdef(sym.owner.defowner),static_name,sym,srsymtable,[ssf_search_helper]) else diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 2994f81938..2d12e5d862 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -1194,7 +1194,7 @@ implementation fieldvarsym : begin { generate access code } - if not handle_staticfield_access(sym,false,p1) then + if not handle_staticfield_access(sym,p1) then propaccesslist_to_node(p1,st,propaccesslist); include(p1.flags,nf_isproperty); consume(_ASSIGNMENT); @@ -1224,7 +1224,7 @@ implementation fieldvarsym : begin { generate access code } - if not handle_staticfield_access(sym,false,p1) then + if not handle_staticfield_access(sym,p1) then propaccesslist_to_node(p1,st,propaccesslist); include(p1.flags,nf_isproperty); { catch expressions like "(propx):=1;" } @@ -1331,7 +1331,7 @@ implementation end; fieldvarsym: begin - if not handle_staticfield_access(sym,true,p1) then + if not handle_staticfield_access(sym,p1) then begin if isclassref then if assigned(p1) and diff --git a/tests/webtbs/tw29030.pp b/tests/webtbs/tw29030.pp new file mode 100644 index 0000000000..66a87ca3ab --- /dev/null +++ b/tests/webtbs/tw29030.pp @@ -0,0 +1,19 @@ +program fpc_nestedtype_ice; + +{$mode delphiunicode} + +Type + TRec = Record + Type + NestedType = Record + Class Var + FVar : Integer; + Class Property Variable : Integer Read FVar Write FVar; + End; + End; + +Begin + TRec.NestedType.Variable := 1; + if TRec.NestedType.Variable<>1 then + halt(1); +End.