浏览代码

* count references to class fields/messages from outside that class'
own methods (mantis #8090)

git-svn-id: trunk@5870 -

Jonas Maebe 18 年之前
父节点
当前提交
45e9633f97
共有 3 个文件被更改,包括 51 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 3 0
      compiler/symtable.pas
  3. 47 0
      tests/webtbs/tw8090.pp

+ 1 - 0
.gitattributes

@@ -7949,6 +7949,7 @@ tests/webtbs/tw7975a.pp svneol=native#text/plain
 tests/webtbs/tw8018.pp svneol=native#text/plain
 tests/webtbs/tw8028.pp svneol=native#text/plain
 tests/webtbs/tw8049.pp svneol=native#text/plain
+tests/webtbs/tw8090.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/uw0555.pp svneol=native#text/plain

+ 3 - 0
compiler/symtable.pas

@@ -1630,6 +1630,7 @@ implementation
             if assigned(srsym) and
                tsym(srsym).is_visible_for_object(contextclassh,currentclassh) then
               begin
+                addsymref(srsym);
                 result:=true;
                 exit;
               end;
@@ -1661,6 +1662,7 @@ implementation
                     srdef:=def;
                     srsym:=tprocdef(def).procsym;
                     srsymtable:=classh.symtable;
+                    addsymref(srsym);
                     result:=true;
                     exit;
                   end;
@@ -1692,6 +1694,7 @@ implementation
                   begin
                     srsym:=tprocdef(def).procsym;
                     srsymtable:=classh.symtable;
+                    addsymref(srsym);
                     result:=true;
                     exit;
                   end;

+ 47 - 0
tests/webtbs/tw8090.pp

@@ -0,0 +1,47 @@
+{ %opt=-Sen }
+program notusedbug;
+
+{$mode objfpc}{$H+}
+
+uses
+  Classes, SysUtils
+  { add your units here };
+  
+type
+  TA = class
+  private
+    FC: integer;
+  end;
+  
+  { TB }
+
+  TB = class
+  private FA: TA;
+  public
+    constructor Create;
+    destructor Destroy; override;
+  end;
+
+{ TB }
+
+constructor TB.Create;
+begin
+  FA := TA.Create;
+  FA.FC := 4;
+  writeln(FA.FC);
+end;
+
+destructor TB.Destroy;
+begin
+  FA.Free;
+  inherited Destroy;
+end;
+
+var
+  b: TB;
+
+begin
+  b := TB.Create;
+  b.Free;
+end.
+