This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libobjc/50003] New: -[Protocol respondsTo:] does not work with Clang


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50003

           Summary: -[Protocol respondsTo:] does not work with Clang
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libobjc
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: nicola@gcc.gnu.org


Jonathan Schleifer reports --

Hi!

When using -[Protocol respondsTo:] in the new GNU runtime, it seems to return
NO, even if the object conforms to the protocol. The code I use is this:

+ (BOOL)conformsToProtocol: (Protocol*)protocol                                 
{
       Class c;
       struct objc_protocol_list *pl;
       size_t i;

       for (c = self; c != Nil; c = class_get_super_class(c))                 
               for (pl = c->protocols; pl != NULL; pl = pl->next)             
                       for (i = 0; i < pl->count; i++)                         
                               if ([pl->list[i] conformsTo: protocol])         
                                       return YES;                             

       return NO;              
}

It works when just using gcc 4.6.1, and it seems to work with older versions of
the GNU runtime.

Thanks

PS: For clarity, Jonathan uses the GCC Objective-C runtime with other 
Objective-C compilers as well, such as clang.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]