Browse Source

* don't allow properties to expose private fields of parent classes
(mantis #14650)

git-svn-id: trunk@13794 -

Jonas Maebe 16 years ago
parent
commit
1eceb2ca65
4 changed files with 36 additions and 0 deletions
  1. 2 0
      .gitattributes
  2. 3 0
      compiler/pdecvar.pas
  3. 16 0
      tests/webtbf/tw14650.pp
  4. 15 0
      tests/webtbf/tw14650a.pp

+ 2 - 0
.gitattributes

@@ -8711,6 +8711,8 @@ tests/webtbf/tw14104b.pp svneol=native#text/plain
 tests/webtbf/tw14104c.pp svneol=native#text/plain
 tests/webtbf/tw14248.pp svneol=native#text/plain
 tests/webtbf/tw1432.pp svneol=native#text/plain
+tests/webtbf/tw14650.pp svneol=native#text/plain
+tests/webtbf/tw14650a.pp svneol=native#text/plain
 tests/webtbf/tw1467.pp svneol=native#text/plain
 tests/webtbf/tw1483.pp svneol=native#text/plain
 tests/webtbf/tw1599.pp svneol=native#text/plain

+ 3 - 0
compiler/pdecvar.pas

@@ -88,6 +88,9 @@ implementation
                  searchsym(pattern,sym,srsymtable);
                if assigned(sym) then
                 begin
+                  if assigned(aclass) and
+                     not is_visible_for_object(sym,aclass) then
+                    Message(parser_e_cant_access_private_member);
                   case sym.typ of
                     fieldvarsym :
                       begin

+ 16 - 0
tests/webtbf/tw14650.pp

@@ -0,0 +1,16 @@
+{ %fail }
+
+{$mode objfpc}
+
+type
+  tc = class
+    strict private
+      fa: longint;
+  end;
+
+  tcc = class(tc)
+    property a: longint read fa;
+  end;
+
+begin
+end.

+ 15 - 0
tests/webtbf/tw14650a.pp

@@ -0,0 +1,15 @@
+{ %fail }
+
+{$mode objfpc}
+
+uses
+  classes;
+
+type
+  TPublicQueueList = class(tfplist)
+  public
+    property List: PPointerList read FList;
+  end;
+
+begin
+end.