فهرست منبع

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

git-svn-id: trunk@21273 -
paul 13 سال پیش
والد
کامیت
62b59235ca
3فایلهای تغییر یافته به همراه45 افزوده شده و 1 حذف شده
  1. 1 0
      .gitattributes
  2. 3 1
      compiler/pexpr.pas
  3. 41 0
      tests/webtbs/tw21941.pp

+ 1 - 0
.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

+ 3 - 1
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

+ 41 - 0
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.
+