compiler: fix accessing typed constants inside class declaration (bug #21941)

git-svn-id: trunk@21273 -
This commit is contained in:
paul 2012-05-12 01:09:56 +00:00
parent b3595893c8
commit 62b59235ca
3 changed files with 45 additions and 1 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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

41
tests/webtbs/tw21941.pp Normal file
View File

@ -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.