This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [objc] -Wselector when there are no @implementation:s



On Jan 26, 2005, at 5:05 PM, Alexander Malmberg wrote:


While working on PR18862, I found another bug in the -Wselector code: the warnings are only issued if there's an @implementation (class or category) somewhere in the file. selector-3.m shows this; a more realistic but less minimal example would be something like:
@interface Foo
-(void) foo;
@end
void quux(void)
{
@selector(f00);
}
The reason is that the code in build_selector_translation_table that issues the warnings is guarded by:
if (warn_selector && objc_implementation_context)
build_selector_translation_table is called by finish_objc, and just before this call, finish_objc walks the list of implementations and sets objc_implementation_context to each one in turn. Thus, if there were any implementations, objc_implementation_context will be set to the last one in the list, and thus be non-NULL, when build_selector_translation_table is called; otherwise, it'll be NULL (earlier parts of finish_objc ensure this) and the warnings won't be issued.
I've attached a patch that fixes this by not checking objc_implementation_context before issuing the warnings. Bootstrapped (c,objc) on i686-pc-linux-gnu. 'make check-objc' has no new failures. I've verified that the new test fails on an unpatched compiler.
(The objc_implementation_context check has been there since the code was added by:
2002-08-08 Devang Patel <dpatel@apple.com>
so perhaps Devang Patel can comment on why it's there, or if there's any reason to keep it. :)

Original intention was to warn inside @implementation only. It is up to ObjC maintainers to decide whether to extend its scope or not.


-
Devang



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]