[cfe-dev] Name lookup in ObjC methods

PARIBORZ JAHANIAN fjahanian at apple.com
Sat Mar 22 10:55:07 PDT 2008


On Mar 21, 2008, at 4:53 AM, Argiris Kirtzidis wrote:

> Chris Lattner wrote:
>>>> int foo::test2(q r) {
>>>>  return X+r;
>>>> }
>>>>
>>> This is actually quite tricky, because clang currently assumes  
>>> that a
>>> declaration can be "found"
>>> only by using an identifier (support for '::' in "foo::test2"  
>>> needed),
>>> and for name lookup it
>>> assumes that the declaration is accessible at the current scope or
>>> at an
>>> enclosing scope of the
>>> current one (support for resolving X in "return X+r;" needed).
>>>
>>
>> It's not that bad, we already handle it for instance variables in  
>> ObjC.
> Actually, name lookup in ObjC methods is not working correctly. For  
> example:
>
> ------------------------------------------------------
> @interface Test {
>    int x;
> }
>
> -(void) setX: (int) d;
> @end
>
> char *x;
>
> @implementation Test
>
> -(void) setX: (int) n {
>    x = n;
> }
>
> @end
> ------------------------------------------------------
>
> If you compile it with "clang test.m -fsyntax-only -pedantic-errors"
> you'll get:
>
> main.m:13:7: error: incompatible integer to pointer conversion  
> assigning
> 'int', expected 'char *'
>    x = n;
>      ^ ~
>
> I'm not familiar with Objective C, but isn't it supposed to pick up  
> the
> 'x' instance variable instead of the global one ?
Yes. This is a clang bug.

- Farborz

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