浏览代码

* fixed wrong "assigned but not used" note for class and interface
(the latter via a type cast) variables from which only fields are
read

git-svn-id: trunk@4181 -

Jonas Maebe 19 年之前
父节点
当前提交
30ee3416e8
共有 3 个文件被更改,包括 28 次插入1 次删除
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/htypechk.pas
  3. 22 0
      tests/tbs/tb0501.pp

+ 1 - 0
.gitattributes

@@ -5762,6 +5762,7 @@ tests/tbs/tb0497c.pp -text
 tests/tbs/tb0498.pp svneol=native#text/plain
 tests/tbs/tb0499.pp svneol=native#text/plain
 tests/tbs/tb0500.pp svneol=native#text/plain
+tests/tbs/tb0501.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain

+ 5 - 1
compiler/htypechk.pas

@@ -790,7 +790,11 @@ implementation
                  p:=tunarynode(p).left;
                end;
              subscriptn :
-               p:=tunarynode(p).left;
+               begin
+                 if is_class_or_interface(tunarynode(p).left.resulttype.def) then
+                   newstate := vs_read;
+                 p:=tunarynode(p).left;
+               end;
              vecn:
                begin
                  set_varstate(tbinarynode(p).right,vs_read,[vsf_must_be_valid]);

+ 22 - 0
tests/tbs/tb0501.pp

@@ -0,0 +1,22 @@
+{ %OPT=-Sen }
+
+{$mode objfpc}
+
+type
+  tc = class
+    procedure t;
+    private
+      fleft: tc;
+  end;
+
+procedure tc.t;
+var
+  oldroot: tc;
+begin
+  fleft := nil;
+  oldroot := nil;
+  oldroot.fleft := nil;
+end;
+
+begin
+end.