This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Objective-C testsuite patch
- To: gcc-patches at gcc dot gnu dot org
- Subject: Objective-C testsuite patch
- From: Ovidiu Predescu <ovidiu at cup dot hp dot com>
- Date: Wed, 28 Feb 2001 09:32:33 -0800
- Cc: Nicola Pero <n dot pero at mi dot flashnet dot it>
Hi,
I've checked in some new test changes for Objective-C from Nicola Pero.
Ovidiu
2001-02-28 Ovidiu Predescu <ovidiu@cup.hp.com>
* objc/execute/bycopy-3.m: Added new test from Nicola Pero.
* objc/execute/protocol.m (main): Added (patch from Nicola Pero).
diff -u /dev/null bycopy-3.m
--- /dev/null Mon Jan 29 21:26:10 2001
+++ bycopy-3.m Wed Feb 28 09:01:59 2001
@@ -0,0 +1,69 @@
+/*
+ * Contributed by Nicola Pero <nicola@brainstorm.co.uk>
+ * Wed Feb 28 12:27:03 CET 2001
+ */
+
+/*
+ * This test contains some no-op code which is needed to keep it
+ * compile on broken gcc 3.x. Anyway, the no-op code does not
+ * interfere with what we are testing, which is that the `bycopy'
+ * keyword generates the _F_BYCOPY qualifier for the return type. */
+
+#include <objc/objc.h>
+#include <objc/Object.h>
+#include <objc/Protocol.h>
+#include <objc/encoding.h>
+
+@protocol MyProtocol
++ (bycopy id<MyProtocol>) bycopyMethod;
+@end
+
+/* This no-op class to keep it compile under broken gcc 3.x */
+@interface MyObject : Object <MyProtocol>
+@end
+
+@implementation MyObject
++ (bycopy id<MyProtocol>) bycopyMethod
+{
+ return [MyObject alloc];
+}
+@end
+
+int main (void)
+{
+ struct objc_method_description *method;
+ const char *method_types;
+ unsigned qualifiers;
+ Protocol *protocol;
+ /* This no-op command is needed to keep the test compile on broken
+ gcc 3.x */
+ MyObject *object = [MyObject bycopyMethod];
+
+ /* Get the protocol object */
+ protocol = @protocol (MyProtocol);
+
+ /* Ask to the protocol for the description of the method bycopyMethod */
+ method = [protocol descriptionForClassMethod: @selector (bycopyMethod)];
+ if (method == NULL)
+ {
+ printf ("Could not find method bycopyMethod in protocol!\n");
+ exit (1);
+ }
+
+ /* Get the method types for the method - which encode return type,
+ arguments etc. */
+ method_types = method->types;
+
+ /* Get the qualifiers for the return type */
+ qualifiers = objc_get_type_qualifiers (method_types);
+
+ /* If _F_BYCOPY is not there, the compiler is broken */
+ if (! (qualifiers & _F_BYCOPY))
+ {
+ printf ("Failed - selector does not contain _F_BYCOPY qualifier!\n");
+ exit (1);
+ }
+
+ /* Else, happy end */
+ return 0;
+}
Index: protocol.m
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/objc/execute/protocol.m,v
retrieving revision 1.1
diff -u -c -r1.1 protocol.m
*** protocol.m 2000/12/14 22:02:18 1.1
--- protocol.m 2001/02/28 16:54:52
***************
*** 14,16 ****
--- 14,21 ----
}
@end
+ int main (void)
+ {
+ return 0;
+ }
+