Browse Source

* always mark symbols referenced by properties as "used"; in case the
property is private, the "used" tracking of the property itself will
indicate whether the symbol is actually used (mantis #22155)

git-svn-id: trunk@23070 -

Jonas Maebe 12 years ago
parent
commit
a1923f02f8
3 changed files with 43 additions and 4 deletions
  1. 1 0
      .gitattributes
  2. 2 4
      compiler/pdecvar.pas
  3. 40 0
      tests/webtbs/tw22155.pp

+ 1 - 0
.gitattributes

@@ -12940,6 +12940,7 @@ tests/webtbs/tw2210.pp svneol=native#text/plain
 tests/webtbs/tw22133.pp svneol=native#text/plain
 tests/webtbs/tw2214.pp svneol=native#text/plain
 tests/webtbs/tw22154.pp svneol=native#text/pascal
+tests/webtbs/tw22155.pp svneol=native#text/plain
 tests/webtbs/tw22160a1.pp svneol=native#text/pascal
 tests/webtbs/tw22160b1.pp svneol=native#text/pascal
 tests/webtbs/tw2220.pp svneol=native#text/plain

+ 2 - 4
compiler/pdecvar.pas

@@ -103,15 +103,13 @@ implementation
                   case sym.typ of
                     fieldvarsym :
                       begin
-                        if (symtablestack.top.currentvisibility<>vis_private) then
-                          addsymref(sym);
+                        addsymref(sym);
                         pl.addsym(sl_load,sym);
                         def:=tfieldvarsym(sym).vardef;
                       end;
                     procsym :
                       begin
-                        if (symtablestack.top.currentvisibility<>vis_private) then
-                          addsymref(sym);
+                        addsymref(sym);
                         pl.addsym(sl_call,sym);
                       end;
                     else

+ 40 - 0
tests/webtbs/tw22155.pp

@@ -0,0 +1,40 @@
+{ %opt=-vn -Sen }
+
+{$MODE DELPHI}
+{.$DEFINE ALT_MODE}
+
+type
+  TWrapper = class
+  strict private
+    type
+      TInternals = record
+        class procedure Z; static;
+      end;
+    class var
+      FInternals: TInternals;
+  private
+    class property Internals: TInternals read FInternals;
+  public
+    procedure Z;
+  end;
+
+class procedure TWrapper.TInternals.Z;
+begin
+end;
+
+procedure TWrapper.Z;
+begin
+{$IFNDEF ALT_MODE}
+  Internals.Z;   { Class variable FInternals “unused” }
+{$ELSE}
+  FInternals.Z;  { Class property Internals “unused” }
+{$ENDIF}
+end;
+
+
+begin
+  with TWrapper.Create do begin
+    Z;
+    Free;
+  end;
+end.