Browse Source

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

git-svn-id: trunk@5870 -

Jonas Maebe 18 years ago
parent
commit
45e9633f97
3 changed files with 51 additions and 0 deletions
  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/tw8018.pp svneol=native#text/plain
 tests/webtbs/tw8028.pp svneol=native#text/plain
 tests/webtbs/tw8028.pp svneol=native#text/plain
 tests/webtbs/tw8049.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/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/uw0555.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
             if assigned(srsym) and
                tsym(srsym).is_visible_for_object(contextclassh,currentclassh) then
                tsym(srsym).is_visible_for_object(contextclassh,currentclassh) then
               begin
               begin
+                addsymref(srsym);
                 result:=true;
                 result:=true;
                 exit;
                 exit;
               end;
               end;
@@ -1661,6 +1662,7 @@ implementation
                     srdef:=def;
                     srdef:=def;
                     srsym:=tprocdef(def).procsym;
                     srsym:=tprocdef(def).procsym;
                     srsymtable:=classh.symtable;
                     srsymtable:=classh.symtable;
+                    addsymref(srsym);
                     result:=true;
                     result:=true;
                     exit;
                     exit;
                   end;
                   end;
@@ -1692,6 +1694,7 @@ implementation
                   begin
                   begin
                     srsym:=tprocdef(def).procsym;
                     srsym:=tprocdef(def).procsym;
                     srsymtable:=classh.symtable;
                     srsymtable:=classh.symtable;
+                    addsymref(srsym);
                     result:=true;
                     result:=true;
                     exit;
                     exit;
                   end;
                   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.
+