Browse Source

compiler: fix private and protected members visibility check for nested records (issue #0018768)

git-svn-id: trunk@19000 -
paul 14 years ago
parent
commit
389c033a29
4 changed files with 32 additions and 5 deletions
  1. 1 0
      .gitattributes
  2. 4 4
      compiler/symtable.pas
  3. 1 1
      tests/webtbs/tw18767a.pp
  4. 26 0
      tests/webtbs/tw18768.pp

+ 1 - 0
.gitattributes

@@ -11714,6 +11714,7 @@ tests/webtbs/tw18702.pp svneol=native#text/pascal
 tests/webtbs/tw1873.pp svneol=native#text/plain
 tests/webtbs/tw1873.pp svneol=native#text/plain
 tests/webtbs/tw18767a.pp svneol=native#text/pascal
 tests/webtbs/tw18767a.pp svneol=native#text/pascal
 tests/webtbs/tw18767b.pp svneol=native#text/pascal
 tests/webtbs/tw18767b.pp svneol=native#text/pascal
+tests/webtbs/tw18768.pp svneol=native#text/pascal
 tests/webtbs/tw1883.pp svneol=native#text/plain
 tests/webtbs/tw1883.pp svneol=native#text/plain
 tests/webtbs/tw18859.pp svneol=native#text/plain
 tests/webtbs/tw18859.pp svneol=native#text/plain
 tests/webtbs/tw1888.pp svneol=native#text/plain
 tests/webtbs/tw1888.pp svneol=native#text/plain

+ 4 - 4
compiler/symtable.pas

@@ -1856,8 +1856,8 @@ implementation
                        (symownerdef.owner.symtabletype in [globalsymtable,staticsymtable]) and
                        (symownerdef.owner.symtabletype in [globalsymtable,staticsymtable]) and
                        (symownerdef.owner.iscurrentunit)
                        (symownerdef.owner.iscurrentunit)
                       ) or
                       ) or
-                      ( // the case of specialize inside the generic declaration
-                       (symownerdef.owner.symtabletype = objectsymtable) and
+                      ( // the case of specialize inside the generic declaration and nested types
+                       (symownerdef.owner.symtabletype in [objectsymtable,recordsymtable]) and
                        (
                        (
                          assigned(current_structdef) and
                          assigned(current_structdef) and
                          (
                          (
@@ -1905,8 +1905,8 @@ implementation
                         (contextobjdef.owner.iscurrentunit) and
                         (contextobjdef.owner.iscurrentunit) and
                         contextobjdef.is_related(symownerdef)
                         contextobjdef.is_related(symownerdef)
                        ) or
                        ) or
-                       ( // the case of specialize inside the generic declaration
-                        (symownerdef.owner.symtabletype = objectsymtable) and
+                       ( // the case of specialize inside the generic declaration and nested types
+                        (symownerdef.owner.symtabletype in [objectsymtable,recordsymtable]) and
                         (
                         (
                           assigned(current_structdef) and
                           assigned(current_structdef) and
                           (
                           (

+ 1 - 1
tests/webtbs/tw18767a.pp

@@ -1,5 +1,5 @@
 { %norun}
 { %norun}
-program tw18767a.pp;
+program tw18767a;
 
 
 {$mode delphi}{$H+}
 {$mode delphi}{$H+}
 
 

+ 26 - 0
tests/webtbs/tw18768.pp

@@ -0,0 +1,26 @@
+{ %norun}
+program tw18768;
+
+{$mode delphi}{$H+}
+
+type
+  TFoo1 = record
+  private
+    type
+      TFoo3 = record
+      private
+        b, c: integer;
+      protected
+        a: integer;
+      public
+        function GetFoo2: integer;
+      end;
+  end;
+
+function TFoo1.TFoo3.GetFoo2: integer;
+begin
+  c := a * b;
+end;
+
+begin
+end.