This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFA] libobjc Protocol isEqual: test class
- From: David Ayers <d dot ayers at inode dot at>
- To: "gcc-patches at gcc dot gnu dot org Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 03 Jun 2004 19:10:34 +0200
- Subject: [RFA] libobjc Protocol isEqual: test class
Hello,
this patch fixes the isEqual: implementation of Protocol in libobjc to
insure that the argument is of the correct class.
Bootstrapped and tested on i686-pc-linux-gnu.
If approved please install as I do not have write privileges.
Cheers,
David
2004-06-03 David Ayers <d.ayers@inode.at>
* Protocol.m ([-isEqual:]): Test the class of the argument.
Index: libobjc/Protocol.m
===================================================================
RCS file: /cvsroot/gcc/gcc/libobjc/Protocol.m,v
retrieving revision 1.6
diff -u -r1.6 Protocol.m
--- libobjc/Protocol.m 25 May 2004 19:10:52 -0000 1.6
+++ libobjc/Protocol.m 3 Jun 2004 16:58:25 -0000
@@ -152,7 +152,8 @@
- (BOOL) isEqual: (id)obj
{
- if (strcmp (protocol_name, [obj name]) == 0)
+ if ([obj isKindOf: [Protocol class]]
+ && strcmp (protocol_name, [obj name]) == 0)
return YES;
return NO;
Index: gcc/testsuite/objc/execute/protocol.m
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/testsuite/objc/execute/protocol.m,v
retrieving revision 1.2
diff -u -r1.2 protocol.m
--- gcc/testsuite/objc/execute/protocol.m 28 Feb 2001 16:58:04 -0000 1.2
+++ gcc/testsuite/objc/execute/protocol.m 3 Jun 2004 16:58:25 -0000
@@ -1,8 +1,9 @@
+#include <objc/Protocol.h>
@protocol Foo
- (void)foo;
@end
-@interface Foo_c <Foo>
+@interface Foo_c : Object <Foo>
{
}
- (void)foo;
@@ -14,8 +15,15 @@
}
@end
+@interface Foo : Foo_c
+@end
+@implementation Foo
+@end
+
int main (void)
{
+ if ([@protocol(Foo) isEqual: [Foo class]])
+ abort();
return 0;
}