Преглед изворни кода

* don't show notes about "unused" private fields of external obj-c class
declarations (since even though they're not used in the Pascal code,
they probably are in the Objective-C code that actually implements them)

git-svn-id: branches/objc@13764 -

Jonas Maebe пре 16 година
родитељ
комит
046b652c28
2 измењених фајлова са 18 додато и 4 уклоњено
  1. 4 2
      compiler/pdecl.pas
  2. 14 2
      compiler/symdef.pas

+ 4 - 2
compiler/pdecl.pas

@@ -528,10 +528,12 @@ implementation
                     { In case of an objcclass, verify that all methods have a message
                       name set. We only check this now, because message names can be set
                       during the protocol (interface) mapping. At the same time, set the
-                      mangled names (these depend on the "external" name of the class).
+                      mangled names (these depend on the "external" name of the class),
+                      and mark private fields of external classes as "used" (to avoid
+                      bogus notes about them being unused)
                     }
                     if is_objc_class_or_protocol(hdef) then
-                      tobjectdef(hdef).check_and_finish_messages;
+                      tobjectdef(hdef).finish_objc_data;
 
                   end;
                 recorddef :

+ 14 - 2
compiler/symdef.pas

@@ -306,7 +306,7 @@ interface
           procedure register_vmt_call(index:longint);
           { ObjC }
           procedure make_all_methods_external;
-          procedure check_and_finish_messages;
+          procedure finish_objc_data;
        end;
 
        tclassrefdef = class(tabstractpointerdef)
@@ -4536,9 +4536,21 @@ implementation
       end;
 
 
-    procedure tobjectdef.check_and_finish_messages;
+    procedure mark_private_fields_used(data: tobject; arg: pointer);
+      var
+        sym: tsym absolute data;
+      begin
+        if (sym.typ=fieldvarsym) and
+           (tfieldvarsym(sym).visibility in [vis_private,vis_strictprivate]) then
+          sym.IncRefCount;
+      end;
+
+
+    procedure tobjectdef.finish_objc_data;
       begin
         self.symtable.DefList.foreachcall(@check_and_finish_msg,nil);
+        if (oo_is_external in objectoptions) then
+          self.symtable.SymList.ForEachCall(@mark_private_fields_used,nil);
       end;