public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libobjc/50003] New: -[Protocol respondsTo:] does not work with Clang
@ 2011-08-06 7:58 nicola at gcc dot gnu.org
2011-10-09 10:47 ` [Bug libobjc/50003] " nicola at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-08-06 7:58 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug libobjc/50003] -[Protocol respondsTo:] does not work with Clang
2011-08-06 7:58 [Bug libobjc/50003] New: -[Protocol respondsTo:] does not work with Clang nicola at gcc dot gnu.org
@ 2011-10-09 10:47 ` nicola at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-10-09 10:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50003
Nicola Pero <nicola at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |WORKSFORME
--- Comment #1 from Nicola Pero <nicola at gcc dot gnu.org> 2011-10-09 10:47:11 UTC ---
With GCC trunk (pre-4.7.0), the code reported can't be used because it's using
the Traditional Objective-C runtime API and not the Modern one.
The right implementation with the Modern API is:
+ (BOOL)conformsToProtocol: (Protocol*)protocol
{
Class c;
for (c = self; c != Nil; c = class_getSuperclass (c))
if (class_conformsToProtocol (c, protocol))
return YES;
return NO;
}
I tested this with both GCC and clang, and it seems to work fine with both.
Thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-10-09 10:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-06 7:58 [Bug libobjc/50003] New: -[Protocol respondsTo:] does not work with Clang nicola at gcc dot gnu.org
2011-10-09 10:47 ` [Bug libobjc/50003] " nicola at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).