[cfe-commits] r75314 - in /cfe/trunk: include/clang/AST/ include/clang/Analysis/PathSensitive/ lib/AST/ lib/Analysis/ lib/CodeGen/ lib/Frontend/ lib/Sema/ test/CodeGenObjC/ test/PCH/ test/SemaObjC/ test/SemaObjCXX/

Fariborz Jahanian fjahanian at apple.com
Mon Jul 13 13:58:58 PDT 2009


On Jul 13, 2009, at 1:18 PM, Chris Lattner wrote:

>>
>> Sure. How about isObjCBuiltinType() and isObjCBuiltinInterface()?

IsObjCIdBuiltinType() and isObjCClassBuiltinType(). Somehow, names  
should convey what they are.

>>
>> GCC warns...
>>
>> test/SemaObjC/comptypes-5.m:29: warning: assignment from distinct  
>> Objective-C type
>> test/SemaObjC/comptypes-5.m:30: warning: assignment from distinct  
>> Objective-C type
>>
>> I decided to allow it. Rationale: Both MyClass and MyOtherClass  
>> implement MyProtocol. Since the protocols "match", and you can  
>> assign any 'id' to an interface type (without warning), I decided  
>> to allow it. I'm happy to put back the warning if others feel  
>> strongly (Fariborz?).
>
> I'll let Fariborz make this call.

We should probably put the warning back.  Lack of a warning looks like  
a clang bug.  For example, clang (and gcc)
both issue warning here:

@protocol MyProtocol
@end

@interface MyClass
@end

int main()
{
   id <MyProtocol> obj_id_p;
   MyClass *obj_c_cat_p;

   obj_c_cat_p = obj_id_p;
   return 0;
}

% $CLANGCC good.m
good.m:12:15: warning: incompatible type assigning 'id<MyProtocol>',  
expected 'MyClass *'
   obj_c_cat_p = obj_id_p;

But if you add a category conforming to the protocol (as in the test),  
then warning disappears in clang. Categories do not
enhance or change the type so behavior should not change.

- Fariborz




>




More information about the cfe-commits mailing list