[cfe-dev] Stricter ObjC warning 'class' may not respond to 'selector'

Volodymyr Sapsai vsapsai at gmail.com
Sun Sep 18 13:08:12 PDT 2011


Have filed a bug http://llvm.org/bugs/show_bug.cgi?id=10956 It might
be not a bug, but at least information that such behavior is
intentional will be available in issue tracker.

On Thu, Sep 15, 2011 at 2:30 AM, Nico Weber <thakis at chromium.org> wrote:
> This is still happening with clang version 3.0 (trunk 139473).
>
> Can you file a bug at http://llvm.org/bugs? (Maybe it's intentional,
> but it looks like a bug to me.)
>
> Nico
>
> On Wed, Sep 14, 2011 at 4:12 PM, Volodymyr Sapsai <vsapsai at gmail.com> wrote:
>> Hi,
>> currently clang compiles following code with a warning "'FooClass' may
>> not respond to 'barMethod'"
>>
>> //foo.h
>> #import <Foundation/NSObject.h>
>> @interface FooClass : NSObject {
>> }
>> - (void)fooMethod;
>> @end
>>
>> //bar.h
>> #import <Foundation/NSObject.h>
>> @interface BarClass : NSObject{
>> }
>> - (void)barMethod;
>> @end
>>
>> //handleFoo.m
>> #import "bar.h"
>> #import "foo.h"
>>
>> void handleFoo(FooClass *foo) {
>>        [foo barMethod];
>> }
>>
>> But if instead of #import "foo.h" we forward declare FooClass, i.e.
>> #import "bar.h"
>> @class FooClass;
>>
>> void handleFoo(FooClass *foo) {
>>        [foo barMethod];
>> }
>>
>> then there is no warning.
>>
>> By currently I mean Apple clang version 2.0 (tags/Apple/clang-139)
>> (based on LLVM 2.9svn) and clang built from r139743.
>>
>> I think it would be useful to emit warning in case of forward
>> declaration. What do you think?
>>
>> Regards,
>> Volodymyr Sapsai
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>




More information about the cfe-dev mailing list