[LLVMbugs] [Bug 7753] cannot initialize a parameter of type 'id<NSMenuDelegate>' with an lvalue of type 'MenuDelegate *'

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 30 09:09:36 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=7753

Fariborz Jahanian <fjahanian at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Fariborz Jahanian <fjahanian at apple.com> 2010-07-30 11:09:35 CDT ---
(In reply to comment #2)
> Created an attachment (id=5288)
 --> (http://llvm.org/bugs/attachment.cgi?id=5288) [details]
> nsMenuX.mii
> 
> OK, I've tried to add --save-temps only to /src/cocoa/ and the entire project.
> I've got the same file both times. Hope this helps.

Thanks for the pre-processed file. clang's complaint is legit and can be shown
in this test case:

@protocol NSMenuDelegate;

@interface GeckoNSMenu
- (void)setDelegate:(id <NSMenuDelegate> )anObject ;
@end

@interface MenuDelegate 
@end

MenuDelegate* mMenuDelegate;

GeckoNSMenu* CreateMenuWithGeckoString()
{
  GeckoNSMenu* myMenu;
  [myMenu setDelegate:mMenuDelegate];
}

'mMenuDelegate' 's type is 'MenuDelegate*' which does not implement the
'NSMenuDelegate' protocol.
Note that gcc issues a warning in this case:
% gcc -c test.mm
test.mm: In function ‘GeckoNSMenu* CreateMenuWithGeckoString()’:
test.mm:15: warning: class 'MenuDelegate' does not implement the
'NSMenuDelegate' protocol

To fix it is the obvious:

% diff nsMenuX.mii nsMenuX.fixit.mii
132607c132607
<   MenuDelegate* mMenuDelegate;
---
>   MenuDelegate<NSMenuDelegate>* mMenuDelegate;

-- 
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