From 62b59235ca71514377319fc85024d21abf7bf9e3 Mon Sep 17 00:00:00 2001 From: paul Date: Sat, 12 May 2012 01:09:56 +0000 Subject: [PATCH] compiler: fix accessing typed constants inside class declaration (bug #21941) git-svn-id: trunk@21273 - --- .gitattributes | 1 + compiler/pexpr.pas | 4 +++- tests/webtbs/tw21941.pp | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw21941.pp diff --git a/.gitattributes b/.gitattributes index 4052f7d09d..7989ac183b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12586,6 +12586,7 @@ tests/webtbs/tw2185.pp svneol=native#text/plain tests/webtbs/tw2186.pp svneol=native#text/plain tests/webtbs/tw2187.pp svneol=native#text/plain tests/webtbs/tw21878.pp svneol=native#text/plain +tests/webtbs/tw21941.pp svneol=native#text/pascal tests/webtbs/tw21951.pp svneol=native#text/plain tests/webtbs/tw2196.pp svneol=native#text/plain tests/webtbs/tw2197.pp svneol=native#text/plain diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 09e2add3bc..9c7000dbc8 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -2254,7 +2254,9 @@ implementation if (srsymtable.symtabletype in [ObjectSymtable,recordsymtable]) then { if we are accessing a owner procsym from the nested } { class we need to call it as a class member } - if assigned(current_structdef) and (current_structdef<>hdef) and is_owned_by(current_structdef,hdef) then + if assigned(current_structdef) and + (((current_structdef<>hdef) and is_owned_by(current_structdef,hdef)) or + (sp_static in srsym.symoptions)) then p1:=cloadvmtaddrnode.create(ctypenode.create(hdef)) else if assigned(current_procinfo) and current_procinfo.procdef.no_self_node then diff --git a/tests/webtbs/tw21941.pp b/tests/webtbs/tw21941.pp new file mode 100644 index 0000000000..2d9d06109c --- /dev/null +++ b/tests/webtbs/tw21941.pp @@ -0,0 +1,41 @@ +{%norun} +program tw21941; + +{$mode objfpc}{$H+} + +type + TACLInfo = record + Name: string; + end; + PACLInfo = ^TACLInfo; + + TCLSInfo = record + Name: string; + end; + PCLSInfo = ^TCLSInfo; + + TCoreObjectInfo = record + CLSInfo: PCLSInfo; + ACLInfo: PACLInfo; + end; + +type + Root = class + type + Test = class + const + ACLInfo: TACLInfo = ( + Name: 'Admin'; + ); + CLSInfo: TCLSInfo = ( + Name: 'TAdminCore'; + ); + Header: TCoreObjectInfo = ( + CLSInfo: @CLSInfo; + ACLInfo: @ACLInfo; + ); + end; + end; +begin +end. +