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

Nico Weber thakis at chromium.org
Wed Sep 14 16:30:08 PDT 2011


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