[LLVMbugs] [Bug 10164] New: Issue with objc_method_family(init) in class extension.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jun 21 00:52:59 PDT 2011


           Summary: Issue with objc_method_family(init) in class
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: devlists at shadowlab.org
                CC: llvmbugs at cs.uiuc.edu

When using the objc_method_family(init) attribute in class extension, clang
does not properly infer the return type and emit a diagnostic to tell it
mismatch (whatever you set as return type).

---------- method_family_init.m
@interface Foo {}

@interface Foo() 
- (id)myinit __attribute__((objc_method_family(init)));

@implementation Foo
- (id)myinit { return self; }

% clang -c method_family_init.m
method_family_init.m:9:1: warning: method is expected to return an instance of
its class type 'Foo', but is declared to return 'id'
- (id)myinit { return self; }
^  ~~
method_family_init.m:5:1: note: overridden method is part of the 'init' method
- (id)myinit __attribute__((objc_method_family(init)));
1 warning generated.

Note that setting the return type to (Foo *) will not solve the issue as clang
expect 'Foo' and not 'Foo *', which is meaningless in Obj-C.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list