summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc
diff options
context:
space:
mode:
authorOvidiu Predescu <ovidiu@gcc.gnu.org>2001-02-28 17:05:10 +0000
committerOvidiu Predescu <ovidiu@gcc.gnu.org>2001-02-28 17:05:10 +0000
commitd291a19abe20e9d82d37df555f619b09d76283da (patch)
treed385af21d4aaea47e77b760423a63f6d5b962bc1 /gcc/testsuite/objc
parent10493d77211033957f8e9e562f1564c111b7b335 (diff)
downloadgcc-d291a19abe20e9d82d37df555f619b09d76283da.tar.gz
Added new test from Nicola Pero.
From-SVN: r40123
Diffstat (limited to 'gcc/testsuite/objc')
-rw-r--r--gcc/testsuite/objc/execute/bycopy-3.m69
1 files changed, 69 insertions, 0 deletions
diff --git a/gcc/testsuite/objc/execute/bycopy-3.m b/gcc/testsuite/objc/execute/bycopy-3.m
new file mode 100644
index 00000000000..9c7c0acbadb
--- /dev/null
+++ b/gcc/testsuite/objc/execute/bycopy-3.m
@@ -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;
+}