Browse Source

compiler: fix strict private visibility check for nested types (issue #0018767)

git-svn-id: trunk@18999 -
paul 14 years ago
parent
commit
dd5aa12531
4 changed files with 44 additions and 4 deletions
  1. 2 0
      .gitattributes
  2. 4 4
      compiler/symtable.pas
  3. 19 0
      tests/webtbs/tw18767a.pp
  4. 19 0
      tests/webtbs/tw18767b.pp

+ 2 - 0
.gitattributes

@@ -11712,6 +11712,8 @@ tests/webtbs/tw1867.pp svneol=native#text/plain
 tests/webtbs/tw18690.pp svneol=native#text/plain
 tests/webtbs/tw18702.pp svneol=native#text/pascal
 tests/webtbs/tw1873.pp svneol=native#text/plain
+tests/webtbs/tw18767a.pp svneol=native#text/pascal
+tests/webtbs/tw18767b.pp svneol=native#text/pascal
 tests/webtbs/tw1883.pp svneol=native#text/plain
 tests/webtbs/tw18859.pp svneol=native#text/plain
 tests/webtbs/tw1888.pp svneol=native#text/plain

+ 4 - 4
compiler/symtable.pas

@@ -217,7 +217,7 @@ interface
 
 {*** Search ***}
     procedure addsymref(sym:tsym);
-    function  is_owned_by(childdef,ownerdef:tabstractrecorddef):boolean;
+    function  is_owned_by(childdef,ownerdef:tdef):boolean;
     function  is_visible_for_object(symst:tsymtable;symvisibility:tvisibility;contextobjdef:tabstractrecorddef):boolean;
     function  is_visible_for_object(pd:tprocdef;contextobjdef:tabstractrecorddef):boolean;
     function  is_visible_for_object(sym:tsym;contextobjdef:tabstractrecorddef):boolean;
@@ -1829,11 +1829,11 @@ implementation
        end;
 
 
-    function is_owned_by(childdef,ownerdef:tabstractrecorddef):boolean;
+    function is_owned_by(childdef,ownerdef:tdef):boolean;
       begin
         result:=childdef=ownerdef;
-        if not result and (childdef.owner.symtabletype in [ObjectSymtable,recordsymtable]) then
-          result:=is_owned_by(tabstractrecorddef(childdef.owner.defowner),ownerdef);
+        if not result and assigned(childdef.owner.defowner) then
+          result:=is_owned_by(tdef(childdef.owner.defowner),ownerdef);
       end;
 
     function is_visible_for_object(symst:tsymtable;symvisibility:tvisibility;contextobjdef:tabstractrecorddef):boolean;

+ 19 - 0
tests/webtbs/tw18767a.pp

@@ -0,0 +1,19 @@
+{ %norun}
+program tw18767a.pp;
+
+{$mode delphi}{$H+}
+
+type
+  TFoo = class
+  strict private
+    const
+      n = 3;
+    var
+      x: array[0..1] of record
+        y: array[0..n] of integer;
+      end;
+  end;
+
+begin
+  TFoo.Create;
+end.

+ 19 - 0
tests/webtbs/tw18767b.pp

@@ -0,0 +1,19 @@
+{ %norun}
+program tw18767b;
+
+{$mode delphi}{$H+}
+
+type
+  TFoo = class
+  strict private
+    type
+      TBar = (one, two);
+    var
+      x: array of record
+        y: array[TBar] of integer;
+      end;
+  end;
+
+begin
+  TFoo.Create;
+end.