[cfe-dev] [Obj-C]method lookup for invalid receiver

Jean-Daniel Dupas devlists at shadowlab.org
Thu Apr 22 09:08:06 PDT 2010


I see that when trying to send a message to a non object receiver (not type id but compatible type like void *), clang interprets the receiver as an 'id', but it does not lookup the selector in the global selector pool like it does for 'id' receiver.

It makes clang unable to compile code that GCC accepts:


@interface NSNumber {}
- (long)integerValue;

float test(void *receiver) {
	return  [receiver integerValue];


Of course, I agree that code relying on this must be fixed, but this is true for a bunch of other warnings ;-)

So, if this is not a design choice, I attach a patch that change the behavior to lookup selector when the receiver is not an object (and fixes tests that rely on the old behavior).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: lookup.patch
Type: application/octet-stream
Size: 3852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100422/170c8ef4/attachment.obj>
-------------- next part --------------

-- Jean-Daniel

More information about the cfe-dev mailing list