Browse Source

* count references to symbols accessed via properties (fixes bug #4826)

git-svn-id: trunk@2959 -
Jonas Maebe 19 years ago
parent
commit
3bc040cc45
3 changed files with 38 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 6 1
      compiler/pexpr.pas
  3. 31 0
      tests/webtbs/tw4826.pp

+ 1 - 0
.gitattributes

@@ -6754,6 +6754,7 @@ tests/webtbs/tw4768.pp -text
 tests/webtbs/tw4778.pp svneol=native#text/plain
 tests/webtbs/tw4789.pp svneol=native#text/plain
 tests/webtbs/tw4809.pp svneol=native#text/plain
+tests/webtbs/tw4826.pp svneol=native#text/plain
 tests/webtbs/tw4893a.pp svneol=native#text/plain
 tests/webtbs/tw4893b.pp svneol=native#text/plain
 tests/webtbs/tw4893c.pp svneol=native#text/plain

+ 6 - 1
compiler/pexpr.pas

@@ -152,6 +152,7 @@ implementation
            case plist^.sltype of
              sl_load :
                begin
+                 addsymref(plist^.sym);
                  if not assigned(st) then
                    st:=plist^.sym.owner;
                  { p1 can already contain the loadnode of
@@ -172,7 +173,10 @@ implementation
                   p1:=cloadnode.create(plist^.sym,st);
                end;
              sl_subscript :
-               p1:=csubscriptnode.create(plist^.sym,p1);
+               begin
+                 addsymref(plist^.sym);
+                 p1:=csubscriptnode.create(plist^.sym,p1);
+               end;
              sl_typeconv :
                p1:=ctypeconvnode.create_explicit(p1,plist^.tt);
              sl_absolutetype :
@@ -1032,6 +1036,7 @@ implementation
                          if membercall then
                            include(callflags,cnf_member_call);
                          p1:=ccallnode.create(paras,tprocsym(tpropertysym(sym).writeaccess.firstsym^.sym),st,p1,callflags);
+                         addsymref(tpropertysym(sym).writeaccess.firstsym^.sym);
                          paras:=nil;
                          consume(_ASSIGNMENT);
                          { read the expression }

+ 31 - 0
tests/webtbs/tw4826.pp

@@ -0,0 +1,31 @@
+{ %OPT=-vn -Sen }
+
+{ Source provided for Free Pascal Bug Report 4826 }
+{ Submitted by "Ivo Steinmann" on  2006-02-20 }
+{ e-mail: [email protected] }
+program bug;
+
+{$mode delphi}
+
+type
+  TTest = class
+  private
+    FFoobar: Integer;
+  protected
+    property Foobar: Integer read FFoobar write FFoobar;
+  public
+    constructor Create;
+  end;
+
+constructor TTest.Create;
+begin
+  inherited Create;
+  Foobar := 0;
+end;
+
+var
+  Test: TTest;
+begin
+  Test := TTest.Create;
+  Test.Free;
+end.