From 046b652c28b786b4390e0c9f3fd1e393174e26f3 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 27 Sep 2009 15:28:49 +0000 Subject: [PATCH] * 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 - --- compiler/pdecl.pas | 6 ++++-- compiler/symdef.pas | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/compiler/pdecl.pas b/compiler/pdecl.pas index 5958fd0ed1..edde0940bb 100644 --- a/compiler/pdecl.pas +++ b/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 : diff --git a/compiler/symdef.pas b/compiler/symdef.pas index d43614459b..2fb42a9484 100644 --- a/compiler/symdef.pas +++ b/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;