summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorovidiu <ovidiu@138bc75d-0d04-0410-961f-82ee72b054a4>2001-03-12 06:24:50 +0000
committerovidiu <ovidiu@138bc75d-0d04-0410-961f-82ee72b054a4>2001-03-12 06:24:50 +0000
commit859981763255eb4e3ab67baf4172d16862da3589 (patch)
treeeec4988cc5bbb2fe0a264d8205241c8999fd8ffa
parent0e4ca78062914700730787b2e97b3fd6a8fe1ec6 (diff)
downloadgcc-859981763255eb4e3ab67baf4172d16862da3589.tar.gz
Added.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@40397 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/testsuite/objc/execute/IMP.m39
-rw-r--r--gcc/testsuite/objc/execute/_cmd.m30
-rw-r--r--gcc/testsuite/objc/execute/accessing_ivars.m55
-rw-r--r--gcc/testsuite/objc/execute/class-1.m23
-rw-r--r--gcc/testsuite/objc/execute/class-10.m77
-rw-r--r--gcc/testsuite/objc/execute/class-11.m81
-rw-r--r--gcc/testsuite/objc/execute/class-12.m50
-rw-r--r--gcc/testsuite/objc/execute/class-13.m71
-rw-r--r--gcc/testsuite/objc/execute/class-14.m76
-rw-r--r--gcc/testsuite/objc/execute/class-2.m29
-rw-r--r--gcc/testsuite/objc/execute/class-3.m43
-rw-r--r--gcc/testsuite/objc/execute/class-4.m52
-rw-r--r--gcc/testsuite/objc/execute/class-5.m71
-rw-r--r--gcc/testsuite/objc/execute/class-6.m71
-rw-r--r--gcc/testsuite/objc/execute/class-7.m59
-rw-r--r--gcc/testsuite/objc/execute/class-8.m74
-rw-r--r--gcc/testsuite/objc/execute/class-9.m74
-rw-r--r--gcc/testsuite/objc/execute/class-tests-1.h137
-rw-r--r--gcc/testsuite/objc/execute/class-tests-2.h67
-rw-r--r--gcc/testsuite/objc/execute/compatibility_alias.m12
-rw-r--r--gcc/testsuite/objc/execute/encode-1.m31
-rw-r--r--gcc/testsuite/objc/execute/formal_protocol-1.m44
-rw-r--r--gcc/testsuite/objc/execute/formal_protocol-2.m45
-rw-r--r--gcc/testsuite/objc/execute/formal_protocol-3.m58
-rw-r--r--gcc/testsuite/objc/execute/formal_protocol-4.m40
-rw-r--r--gcc/testsuite/objc/execute/formal_protocol-5.m33
-rw-r--r--gcc/testsuite/objc/execute/formal_protocol-6.m25
-rw-r--r--gcc/testsuite/objc/execute/formal_protocol-7.m44
-rw-r--r--gcc/testsuite/objc/execute/informal_protocol.m13
-rw-r--r--gcc/testsuite/objc/execute/initialize.m36
-rw-r--r--gcc/testsuite/objc/execute/load.m30
-rw-r--r--gcc/testsuite/objc/execute/many_args_method.m56
-rw-r--r--gcc/testsuite/objc/execute/nested-3.m37
-rw-r--r--gcc/testsuite/objc/execute/no_clash.m41
-rw-r--r--gcc/testsuite/objc/execute/private.m32
-rw-r--r--gcc/testsuite/objc/execute/redefining_self.m31
-rw-r--r--gcc/testsuite/objc/execute/root_methods.m42
-rw-r--r--gcc/testsuite/objc/execute/selector-1.m17
-rw-r--r--gcc/testsuite/objc/execute/static-1.m34
-rw-r--r--gcc/testsuite/objc/execute/static-2.m37
-rw-r--r--gcc/testsuite/objc/execute/va_method.m44
41 files changed, 1961 insertions, 0 deletions
diff --git a/gcc/testsuite/objc/execute/IMP.m b/gcc/testsuite/objc/execute/IMP.m
new file mode 100644
index 00000000000..979aebb0158
--- /dev/null
+++ b/gcc/testsuite/objc/execute/IMP.m
@@ -0,0 +1,39 @@
+/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Test getting and calling the IMP of a method */
+
+@interface TestClass
+{
+ Class isa;
+}
+- (int) next: (int)a;
+@end
+
+@implementation TestClass
+- (int) next: (int)a
+{
+ return a + 1;
+}
+@end
+
+
+int main (void)
+{
+ Class class;
+ SEL selector;
+ int (* imp) (id, SEL, int);
+
+ class = objc_get_class ("TestClass");
+ selector = @selector (next:);
+ imp = (int (*)(id, SEL, int))method_get_imp
+ (class_get_class_method (class, selector));
+
+ if (imp (class, selector, 5) != 6)
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/_cmd.m b/gcc/testsuite/objc/execute/_cmd.m
new file mode 100644
index 00000000000..20203b51711
--- /dev/null
+++ b/gcc/testsuite/objc/execute/_cmd.m
@@ -0,0 +1,30 @@
+/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Test the hidden argument _cmd to method calls */
+
+@interface TestClass
+{
+ Class isa;
+}
++ (const char*) method;
+@end
+
+@implementation TestClass
++ (const char*) method;
+{
+ return sel_get_name (_cmd);
+}
+@end
+
+
+int main (void)
+{
+ if (strcmp ([TestClass method], "method"))
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/accessing_ivars.m b/gcc/testsuite/objc/execute/accessing_ivars.m
new file mode 100644
index 00000000000..2c024f5ba7e
--- /dev/null
+++ b/gcc/testsuite/objc/execute/accessing_ivars.m
@@ -0,0 +1,55 @@
+/* Contributed by Nicola Pero - Thu Mar 8 16:27:46 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+#include <objc/Object.h>
+
+/* Test that by using -> we can access ivars of other objects of the same
+ class */
+
+@interface TestClass : Object
+{
+ int value;
+}
+- (int) value;
+- (int) setValue: (int)number;
+- (void) takeValueFrom: (TestClass *)object;
+@end
+
+@implementation TestClass : Object
+{
+ int value;
+}
+- (int) value
+{
+ return value;
+}
+- (int) setValue: (int)number
+{
+ value = number;
+}
+- (void) takeValueFrom: (TestClass *)object
+{
+ value = object->value;
+}
+@end
+
+int main (void)
+{
+ TestClass *a;
+ TestClass *b;
+
+ a = [TestClass new];
+ [a setValue: 10];
+
+ b = [TestClass new];
+ [b setValue: -10];
+
+ [b takeValueFrom: a];
+
+ if ([b value] != [a value])
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-1.m b/gcc/testsuite/objc/execute/class-1.m
new file mode 100644
index 00000000000..a28cfc3abb8
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-1.m
@@ -0,0 +1,23 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a RootClass */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+#include "class-tests-1.h"
+
+int main (void)
+{
+ test_class_with_superclass ("RootClass", "");
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-10.m b/gcc/testsuite/objc/execute/class-10.m
new file mode 100644
index 00000000000..3d9697c0d86
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-10.m
@@ -0,0 +1,77 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass with an ivar and
+ accessor methods and a subclass overriding the superclass'
+ implementation, and using self to call another method of itself */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+@interface SubClass : RootClass
+{
+ int state;
+}
+- (void) setState: (int)number;
+- (int) state;
+@end
+
+@implementation SubClass
+- (void) setState: (int)number
+{
+ state = number;
+}
+- (int) state
+{
+ return state;
+}
+@end
+
+@interface SubSubClass : SubClass
+- (int) shift;
+@end
+
+@implementation SubSubClass
+- (int) state
+{
+ return state + [self shift];
+}
+- (int) shift
+{
+ return 1;
+}
+@end
+
+#include "class-tests-1.h"
+#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
+#include "class-tests-2.h"
+
+int main (void)
+{
+ SubClass *object;
+ SubSubClass *sub_object;
+
+ test_class_with_superclass ("SubClass", "RootClass");
+ test_that_class_has_instance_method ("SubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubClass", @selector (state));
+
+ test_class_with_superclass ("SubSubClass", "SubClass");
+ test_that_class_has_instance_method ("SubSubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubSubClass", @selector (state));
+ test_that_class_has_instance_method ("SubSubClass", @selector (shift));
+
+ object = class_create_instance (objc_lookup_class ("SubClass"));
+ test_accessor_method (object, 0, -1, -1, 1, 1);
+
+ sub_object = class_create_instance (objc_lookup_class ("SubSubClass"));
+ test_accessor_method (sub_object, 1, -1, 0, 1, 2);
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-11.m b/gcc/testsuite/objc/execute/class-11.m
new file mode 100644
index 00000000000..902db2b9a33
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-11.m
@@ -0,0 +1,81 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass with an ivar and
+ accessor methods and a subclass overriding the superclass'
+ implementation and using self to call another method of itself - in
+ a category */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+@interface SubClass : RootClass
+{
+ int state;
+}
+- (void) setState: (int)number;
+- (int) state;
+@end
+
+@implementation SubClass
+- (void) setState: (int)number
+{
+ state = number;
+}
+- (int) state
+{
+ return state;
+}
+@end
+
+@interface SubSubClass : SubClass
+- (int) shift;
+@end
+
+@implementation SubSubClass
+- (int) shift
+{
+ return 1;
+}
+@end
+
+@implementation SubSubClass (Additions)
+- (int) state
+{
+ return state + [self shift];
+}
+@end
+
+#include "class-tests-1.h"
+#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
+#include "class-tests-2.h"
+
+int main (void)
+{
+ SubClass *object;
+ SubSubClass *sub_object;
+
+ test_class_with_superclass ("SubClass", "RootClass");
+ test_that_class_has_instance_method ("SubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubClass", @selector (state));
+
+ test_class_with_superclass ("SubSubClass", "SubClass");
+ test_that_class_has_instance_method ("SubSubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubSubClass", @selector (state));
+ test_that_class_has_instance_method ("SubSubClass", @selector (shift));
+
+ object = class_create_instance (objc_lookup_class ("SubClass"));
+ test_accessor_method (object, 0, -1, -1, 1, 1);
+
+ sub_object = class_create_instance (objc_lookup_class ("SubSubClass"));
+ test_accessor_method (sub_object, 1, -1, 0, 1, 2);
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-12.m b/gcc/testsuite/objc/execute/class-12.m
new file mode 100644
index 00000000000..e65611df06b
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-12.m
@@ -0,0 +1,50 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass with a class methods */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+static int class_variable = 0;
+
+@interface SubClass : RootClass
++ (void) setState: (int)number;
++ (int) state;
+@end
+
+@implementation SubClass
++ (void) setState: (int)number
+{
+ class_variable = number;
+}
++ (int) state
+{
+ return class_variable;
+}
+@end
+
+#include "class-tests-1.h"
+#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class
+#include "class-tests-2.h"
+
+int main (void)
+{
+ Class class;
+
+ test_class_with_superclass ("SubClass", "RootClass");
+ test_that_class_has_class_method ("SubClass", @selector (setState:));
+ test_that_class_has_class_method ("SubClass", @selector (state));
+
+ class = objc_lookup_class ("SubClass");
+ test_accessor_method (class, 0, -1, -1, 1, 1);
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-13.m b/gcc/testsuite/objc/execute/class-13.m
new file mode 100644
index 00000000000..0d87afd9508
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-13.m
@@ -0,0 +1,71 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass with a class accessor
+ methods and a subclass overriding the superclass' implementation
+ but reusing it with super */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+static int class_variable = 0;
+
+@interface SubClass : RootClass
++ (void) setState: (int)number;
++ (int) state;
+@end
+
+@implementation SubClass
++ (void) setState: (int)number
+{
+ class_variable = number;
+}
++ (int) state
+{
+ return class_variable;
+}
+@end
+
+@interface SubSubClass : SubClass
+@end
+
+@implementation SubSubClass
++ (int) state
+{
+ return [super state] + 1;
+}
+@end
+
+#include "class-tests-1.h"
+#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class
+#include "class-tests-2.h"
+
+int main (void)
+{
+ Class class;
+ Class sub_class;
+
+ test_class_with_superclass ("SubClass", "RootClass");
+ test_that_class_has_class_method ("SubClass", @selector (setState:));
+ test_that_class_has_class_method ("SubClass", @selector (state));
+
+ test_class_with_superclass ("SubSubClass", "SubClass");
+ test_that_class_has_class_method ("SubSubClass", @selector (setState:));
+ test_that_class_has_class_method ("SubSubClass", @selector (state));
+
+ class = objc_lookup_class ("SubClass");
+ test_accessor_method (class, 0, -1, -1, 1, 1);
+
+ sub_class = objc_lookup_class ("SubSubClass");
+ class_variable = 0;
+ test_accessor_method (sub_class, 1, -1, 0, 1, 2);
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-14.m b/gcc/testsuite/objc/execute/class-14.m
new file mode 100644
index 00000000000..2827031358c
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-14.m
@@ -0,0 +1,76 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass with a class accessor
+ methods and a subclass overriding the superclass' implementation,
+ and using self to call another method of itself */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+static int class_variable = 0;
+
+@interface SubClass : RootClass
++ (void) setState: (int)number;
++ (int) state;
+@end
+
+@implementation SubClass
++ (void) setState: (int)number
+{
+ class_variable = number;
+}
++ (int) state
+{
+ return class_variable;
+}
+@end
+
+@interface SubSubClass : SubClass
++ (int) shift;
+@end
+
+@implementation SubSubClass
++ (int) state
+{
+ return class_variable + [self shift];
+}
++ (int) shift
+{
+ return 1;
+}
+@end
+
+#include "class-tests-1.h"
+#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class
+#include "class-tests-2.h"
+
+int main (void)
+{
+ Class class, sub_class;
+
+ test_class_with_superclass ("SubClass", "RootClass");
+ test_that_class_has_class_method ("SubClass", @selector (setState:));
+ test_that_class_has_class_method ("SubClass", @selector (state));
+
+ test_class_with_superclass ("SubSubClass", "SubClass");
+ test_that_class_has_class_method ("SubSubClass", @selector (setState:));
+ test_that_class_has_class_method ("SubSubClass", @selector (state));
+ test_that_class_has_class_method ("SubSubClass", @selector (shift));
+
+ class = objc_lookup_class ("SubClass");
+ test_accessor_method (class, 0, -1, -1, 1, 1);
+
+ sub_class = objc_lookup_class ("SubSubClass");
+ class_variable = 0;
+ test_accessor_method (sub_class, 1, -1, 0, 1, 2);
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-2.m b/gcc/testsuite/objc/execute/class-2.m
new file mode 100644
index 00000000000..cb8b47fa1a3
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-2.m
@@ -0,0 +1,29 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+@interface SubClass : RootClass
+@end
+
+@implementation SubClass
+@end
+
+#include "class-tests-1.h"
+
+int main (void)
+{
+ test_class_with_superclass ("SubClass", "RootClass");
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-3.m b/gcc/testsuite/objc/execute/class-3.m
new file mode 100644
index 00000000000..dbe68bf9037
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-3.m
@@ -0,0 +1,43 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a minimal subclass tree */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+@interface SubClassA : RootClass
+@end
+
+@implementation SubClassA
+@end
+
+@interface SubClassB : RootClass
+@end
+
+@implementation SubClassB
+@end
+
+@interface SubSubClass : SubClassA
+@end
+
+@implementation SubSubClass
+@end
+
+#include "class-tests-1.h"
+
+int main (void)
+{
+ test_class_with_superclass ("SubClassA", "RootClass");
+ test_class_with_superclass ("SubClassB", "RootClass");
+ test_class_with_superclass ("SubSubClass", "SubClassA");
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-4.m b/gcc/testsuite/objc/execute/class-4.m
new file mode 100644
index 00000000000..0ae723c035b
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-4.m
@@ -0,0 +1,52 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass with an ivar and
+ accessor methods */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+@interface SubClass : RootClass
+{
+ int state;
+}
+- (void) setState: (int)number;
+- (int) state;
+@end
+
+@implementation SubClass
+- (void) setState: (int)number
+{
+ state = number;
+}
+- (int) state
+{
+ return state;
+}
+@end
+
+#include "class-tests-1.h"
+#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
+#include "class-tests-2.h"
+
+int main (void)
+{
+ SubClass *object;
+
+ test_class_with_superclass ("SubClass", "RootClass");
+ test_that_class_has_instance_method ("SubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubClass", @selector (state));
+
+ object = class_create_instance (objc_lookup_class ("SubClass"));
+ test_accessor_method (object, 0, 1, 1, -3, -3);
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-5.m b/gcc/testsuite/objc/execute/class-5.m
new file mode 100644
index 00000000000..5d5297f6247
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-5.m
@@ -0,0 +1,71 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass with an ivar and
+ accessor methods and a subclass overriding the superclass'
+ implementation */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+@interface SubClass : RootClass
+{
+ int state;
+}
+- (void) setState: (int)number;
+- (int) state;
+@end
+
+@implementation SubClass
+- (void) setState: (int)number
+{
+ state = number;
+}
+- (int) state
+{
+ return state;
+}
+@end
+
+@interface SubSubClass : SubClass
+@end
+
+@implementation SubSubClass
+- (int) state
+{
+ return state + 1;
+}
+@end
+
+#include "class-tests-1.h"
+#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
+#include "class-tests-2.h"
+
+int main (void)
+{
+ SubClass *object;
+ SubSubClass *sub_object;
+
+ test_class_with_superclass ("SubClass", "RootClass");
+ test_that_class_has_instance_method ("SubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubClass", @selector (state));
+
+ test_class_with_superclass ("SubSubClass", "SubClass");
+ test_that_class_has_instance_method ("SubSubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubSubClass", @selector (state));
+
+ object = class_create_instance (objc_lookup_class ("SubClass"));
+ test_accessor_method (object, 0, -1, -1, 1, 1);
+
+ sub_object = class_create_instance (objc_lookup_class ("SubSubClass"));
+ test_accessor_method (sub_object, 1, -1, 0, 1, 2);
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-6.m b/gcc/testsuite/objc/execute/class-6.m
new file mode 100644
index 00000000000..f60912aa608
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-6.m
@@ -0,0 +1,71 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass with an ivar and
+ accessor methods and a subclass overriding the superclass'
+ implementation but reusing it with super */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+@interface SubClass : RootClass
+{
+ int state;
+}
+- (void) setState: (int)number;
+- (int) state;
+@end
+
+@implementation SubClass
+- (void) setState: (int)number
+{
+ state = number;
+}
+- (int) state
+{
+ return state;
+}
+@end
+
+@interface SubSubClass : SubClass
+@end
+
+@implementation SubSubClass
+- (int) state
+{
+ return [super state] + 1;
+}
+@end
+
+#include "class-tests-1.h"
+#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
+#include "class-tests-2.h"
+
+int main (void)
+{
+ SubClass *object;
+ SubSubClass *sub_object;
+
+ test_class_with_superclass ("SubClass", "RootClass");
+ test_that_class_has_instance_method ("SubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubClass", @selector (state));
+
+ test_class_with_superclass ("SubSubClass", "SubClass");
+ test_that_class_has_instance_method ("SubSubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubSubClass", @selector (state));
+
+ object = class_create_instance (objc_lookup_class ("SubClass"));
+ test_accessor_method (object, 0, -1, -1, 1, 1);
+
+ sub_object = class_create_instance (objc_lookup_class ("SubSubClass"));
+ test_accessor_method (sub_object, 1, -1, 0, 1, 2);
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-7.m b/gcc/testsuite/objc/execute/class-7.m
new file mode 100644
index 00000000000..9a2fe0cff41
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-7.m
@@ -0,0 +1,59 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass with an ivar and
+ accessor methods; accessor methods implemented in a separate
+ category */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+@interface SubClass : RootClass
+{
+ int state;
+}
+@end
+
+@implementation SubClass
+@end
+
+@interface SubClass (Additions)
+- (void) setState: (int)number;
+- (int) state;
+@end
+
+@implementation SubClass (Additions)
+- (void) setState: (int)number
+{
+ state = number;
+}
+- (int) state
+{
+ return state;
+}
+@end
+
+#include "class-tests-1.h"
+#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
+#include "class-tests-2.h"
+
+int main (void)
+{
+ SubClass *object;
+
+ test_class_with_superclass ("SubClass", "RootClass");
+ test_that_class_has_instance_method ("SubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubClass", @selector (state));
+
+ object = class_create_instance (objc_lookup_class ("SubClass"));
+ test_accessor_method (object, 0, 1, 1, -3, -3);
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-8.m b/gcc/testsuite/objc/execute/class-8.m
new file mode 100644
index 00000000000..fa111850213
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-8.m
@@ -0,0 +1,74 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass with an ivar and
+ accessor methods and a subclass overriding the superclass'
+ implementation - in a category */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+@interface SubClass : RootClass
+{
+ int state;
+}
+- (void) setState: (int)number;
+- (int) state;
+@end
+
+@implementation SubClass
+- (void) setState: (int)number
+{
+ state = number;
+}
+- (int) state
+{
+ return state;
+}
+@end
+
+@interface SubSubClass : SubClass
+@end
+
+@implementation SubSubClass
+@end
+
+@implementation SubSubClass (Additions)
+- (int) state
+{
+ return state + 1;
+}
+@end
+
+#include "class-tests-1.h"
+#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
+#include "class-tests-2.h"
+
+int main (void)
+{
+ SubClass *object;
+ SubSubClass *sub_object;
+
+ test_class_with_superclass ("SubClass", "RootClass");
+ test_that_class_has_instance_method ("SubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubClass", @selector (state));
+
+ test_class_with_superclass ("SubSubClass", "SubClass");
+ test_that_class_has_instance_method ("SubSubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubSubClass", @selector (state));
+
+ object = class_create_instance (objc_lookup_class ("SubClass"));
+ test_accessor_method (object, 0, -1, -1, 1, 1);
+
+ sub_object = class_create_instance (objc_lookup_class ("SubSubClass"));
+ test_accessor_method (sub_object, 1, -1, 0, 1, 2);
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-9.m b/gcc/testsuite/objc/execute/class-9.m
new file mode 100644
index 00000000000..bb405fbc982
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-9.m
@@ -0,0 +1,74 @@
+/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Tests creating a root class and a subclass with an ivar and
+ accessor methods and a subclass overriding the superclass'
+ implementation but reusing it with super - in a category */
+
+@interface RootClass
+{
+ Class isa;
+}
+@end
+
+@implementation RootClass
+@end
+
+@interface SubClass : RootClass
+{
+ int state;
+}
+- (void) setState: (int)number;
+- (int) state;
+@end
+
+@implementation SubClass
+- (void) setState: (int)number
+{
+ state = number;
+}
+- (int) state
+{
+ return state;
+}
+@end
+
+@interface SubSubClass : SubClass
+@end
+
+@implementation SubSubClass
+@end
+
+@implementation SubSubClass (Additions)
+- (int) state
+{
+ return [super state] + 1;
+}
+@end
+
+#include "class-tests-1.h"
+#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
+#include "class-tests-2.h"
+
+int main (void)
+{
+ SubClass *object;
+ SubSubClass *sub_object;
+
+ test_class_with_superclass ("SubClass", "RootClass");
+ test_that_class_has_instance_method ("SubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubClass", @selector (state));
+
+ test_class_with_superclass ("SubSubClass", "SubClass");
+ test_that_class_has_instance_method ("SubSubClass", @selector (setState:));
+ test_that_class_has_instance_method ("SubSubClass", @selector (state));
+
+ object = class_create_instance (objc_lookup_class ("SubClass"));
+ test_accessor_method (object, 0, -1, -1, 1, 1);
+
+ sub_object = class_create_instance (objc_lookup_class ("SubSubClass"));
+ test_accessor_method (sub_object, 1, -1, 0, 1, 2);
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/class-tests-1.h b/gcc/testsuite/objc/execute/class-tests-1.h
new file mode 100644
index 00000000000..f321df4f335
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-tests-1.h
@@ -0,0 +1,137 @@
+/* Contributed by Nicola Pero on Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+#include <objc/Object.h>
+#include <stdlib.h>
+
+/*
+ * Standard Tests For Classes and Objects - abort upon failing; return
+ * normally if all is well.
+ */
+
+/* Test that `class' is a Class */
+static void test_is_class (Class class)
+{
+ if (object_is_class (class) == NO)
+ {
+ printf ("test_is_class failed\n");
+ abort ();
+ }
+
+ if (class_is_class (class) == NO)
+ {
+ printf ("test_is_class failed\n");
+ abort ();
+ }
+}
+
+/* Test that the superclass of `class' is `superclass' */
+static void test_superclass (Class class, Class superclass)
+{
+ if (class_get_super_class (class) != superclass)
+ {
+ printf ("test_superclass failed\n");
+ abort ();
+ }
+}
+
+/* Test that the classname of `class' is `classname' */
+static void test_class_name (Class class, const char *classname)
+{
+ if (strcmp (class_get_class_name (class), classname))
+ {
+ printf ("test_class_name failed\n");
+ abort ();
+ }
+}
+
+/* Test that we can allocate instances of `class' */
+static void test_allocate (Class class)
+{
+ /* The object we create is leaked but who cares, this is only a test */
+ id object = class_create_instance (class);
+
+ if (object == nil)
+ {
+ printf ("test_allocate failed\n");
+ abort ();
+ }
+}
+
+/* Test that instances of `class' are instances and not classes */
+static void test_instances (Class class)
+{
+ id object = class_create_instance (class);
+
+ if (object_is_class (object) == YES)
+ {
+ printf ("test_instances failed\n");
+ abort ();
+ }
+}
+
+/* Test that we can deallocate instances of `class' */
+static void test_deallocate (Class class)
+{
+ id object = class_create_instance (class);
+
+ object_dispose (object);
+}
+
+/* Test that the object and the class agree on what the class is */
+static void test_object_class (Class class)
+{
+ id object = class_create_instance (class);
+
+ if (object_get_class (object) != class)
+ {
+ printf ("test_object_class failed\n");
+ abort ();
+ }
+}
+
+/* Test that the object and the class agree on what the superclass is */
+static void test_object_super_class (Class class)
+{
+ id object = class_create_instance (class);
+
+ if (object_get_super_class (object) != class_get_super_class (class))
+ {
+ printf ("test_object_super_class failed\n");
+ abort ();
+ }
+}
+
+/*
+ * Runs all the tests in this file for the specified class
+ */
+void test_class_with_superclass (const char *class_name,
+ const char *superclass_name)
+{
+ Class class;
+ Class superclass;
+
+ /* We need at least a method call before playing with the internals,
+ so that the runtime will call __objc_resolve_class_links () */
+ [Object initialize];
+
+ /* class_name must be an existing class */
+ class = objc_lookup_class (class_name);
+ test_is_class (class);
+
+ /* But superclass_name can be "", which means `Nil' */
+ superclass = objc_lookup_class (superclass_name);
+ if (superclass != Nil)
+ {
+ test_is_class (superclass);
+ }
+
+ /* Now the tests */
+ test_superclass (class, superclass);
+ test_class_name (class, class_name);
+ test_allocate (class);
+ test_instances (class);
+ test_deallocate (class);
+ test_object_class (class);
+ test_object_super_class (class);
+}
diff --git a/gcc/testsuite/objc/execute/class-tests-2.h b/gcc/testsuite/objc/execute/class-tests-2.h
new file mode 100644
index 00000000000..6df91df2b6e
--- /dev/null
+++ b/gcc/testsuite/objc/execute/class-tests-2.h
@@ -0,0 +1,67 @@
+/* Contributed by Nicola Pero on Tue Mar 6 23:05:53 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+#include <stdlib.h>
+
+/*
+ * Standard Tests For Methods of Classes and Objects - abort upon
+ * failing; return normally if all is well.
+ */
+
+/* Test that `class' has an instance method for the selector `selector' */
+void test_that_class_has_instance_method (const char *class_name,
+ SEL selector)
+{
+ Class class = objc_lookup_class (class_name);
+
+ if (class_get_instance_method (class, selector) == NULL)
+ {
+ printf ("test_class_has_instance_method failed\n");
+ abort ();
+ }
+}
+
+/* Test that `class' has a class method for the selector `selector' */
+void test_that_class_has_class_method (const char *class_name,
+ SEL selector)
+{
+ Class meta_class = objc_get_meta_class (class_name);
+
+ if (class_get_class_method (meta_class, selector) == NULL)
+ {
+ printf ("test_class_has_class_method failed\n");
+ abort ();
+ }
+}
+
+/* Test the accessor methods (called -state and -setState:) on the
+ object `object'. */
+#ifdef TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD
+void test_accessor_method (TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD object,
+ int initial_state,
+ int new_state_0, int expected_result_0,
+ int new_state_1, int expected_result_1)
+{
+ if ([object state] != initial_state)
+ {
+ printf ("test_accessor_method (initial state) failed\n");
+ abort ();
+ }
+
+ [object setState: new_state_0];
+ if ([object state] != expected_result_0)
+ {
+ printf ("test_accessor_method (new_state_0) failed\n");
+ abort ();
+ }
+
+ [object setState: new_state_1];
+ if ([object state] != expected_result_1)
+ {
+ printf ("test_accessor_method (new_state_1) failed\n");
+ abort ();
+ }
+}
+#endif CLASS_WITH_ACCESSOR_METHOD
+
+
diff --git a/gcc/testsuite/objc/execute/compatibility_alias.m b/gcc/testsuite/objc/execute/compatibility_alias.m
new file mode 100644
index 00000000000..24f47712eec
--- /dev/null
+++ b/gcc/testsuite/objc/execute/compatibility_alias.m
@@ -0,0 +1,12 @@
+/* Contributed by Nicola Pero - Thu Mar 8 17:23:59 CET 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+@compatibility_alias MyObject Object;
+
+int main (void)
+{
+ MyObject *object = [MyObject alloc];
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/encode-1.m b/gcc/testsuite/objc/execute/encode-1.m
new file mode 100644
index 00000000000..3f232c9cdd2
--- /dev/null
+++ b/gcc/testsuite/objc/execute/encode-1.m
@@ -0,0 +1,31 @@
+/* Contributed by Nicola Pero - Thu Mar 8 16:27:46 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+#include <objc/Object.h>
+
+/* Test very simple @encode */
+
+int main (void)
+{
+ if (strcmp ("i", @encode (int)))
+ {
+ abort ();
+ }
+
+ if (strcmp ("@", @encode (id)))
+ {
+ abort ();
+ }
+
+ if (strcmp ("@", @encode (Object *)))
+ {
+ abort ();
+ }
+
+ if (strcmp (":", @encode (SEL)))
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/formal_protocol-1.m b/gcc/testsuite/objc/execute/formal_protocol-1.m
new file mode 100644
index 00000000000..1fde38b794d
--- /dev/null
+++ b/gcc/testsuite/objc/execute/formal_protocol-1.m
@@ -0,0 +1,44 @@
+/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+/* Tests defining a protocol and a class adopting it */
+
+@protocol Enabling
+- (BOOL) isEnabled;
+- (void) setEnabled: (BOOL)flag;
+@end
+
+@interface Feature : Object <Enabling>
+{
+ const char *name;
+ BOOL isEnabled;
+}
+@end
+
+@implementation Feature
+- (BOOL) isEnabled
+{
+ return isEnabled;
+}
+- (void) setEnabled: (BOOL)flag
+{
+ isEnabled = flag;
+}
+@end
+
+int main (void)
+{
+ Feature *object;
+
+ object = [Feature new];
+
+ [object setEnabled: YES];
+ if (![object isEnabled])
+ {
+ abort ();
+ }
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/objc/execute/formal_protocol-2.m b/gcc/testsuite/objc/execute/formal_protocol-2.m
new file mode 100644
index 00000000000..f399555ed14
--- /dev/null
+++ b/gcc/testsuite/objc/execute/formal_protocol-2.m
@@ -0,0 +1,45 @@
+/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+/* Test defining a protocol, a class adopting it, and using an object
+ of type `id <protocol>'. */
+
+@protocol Enabling
+- (BOOL) isEnabled;
+- (void) setEnabled: (BOOL)flag;
+@end
+
+@interface Feature : Object <Enabling>
+{
+ const char *name;
+ BOOL isEnabled;
+}
+@end
+
+@implementation Feature
+- (BOOL) isEnabled
+{
+ return isEnabled;
+}
+- (void) setEnabled: (BOOL)flag
+{
+ isEnabled = flag;
+}
+@end
+
+int main (void)
+{
+ id <Enabling> object;
+
+ object = [Feature new];
+
+ [object setEnabled: YES];
+ if (![object isEnabled])
+ {
+ abort ();
+ }
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/objc/execute/formal_protocol-3.m b/gcc/testsuite/objc/execute/formal_protocol-3.m
new file mode 100644
index 00000000000..9fc2a768ded
--- /dev/null
+++ b/gcc/testsuite/objc/execute/formal_protocol-3.m
@@ -0,0 +1,58 @@
+/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+/* Test defining two protocol, a class adopting both of them,
+ and using an object of type `id <Protocol1, Protocol2>' */
+
+@protocol Enabling
+- (BOOL) isEnabled;
+- (void) setEnabled: (BOOL)flag;
+@end
+
+@protocol Evaluating
+- (int) importance;
+@end
+
+@interface Feature : Object <Enabling, Evaluating>
+{
+ const char *name;
+ BOOL isEnabled;
+}
+@end
+
+@implementation Feature
+- (BOOL) isEnabled
+{
+ return isEnabled;
+}
+- (void) setEnabled: (BOOL)flag
+{
+ isEnabled = flag;
+}
+- (int) importance
+{
+ return 1000;
+}
+@end
+
+int main (void)
+{
+ id <Enabling, Evaluating> object;
+
+ object = [Feature new];
+
+ [object setEnabled: YES];
+ if (![object isEnabled])
+ {
+ abort ();
+ }
+
+ if ([object importance] != 1000)
+ {
+ abort ();
+ }
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/objc/execute/formal_protocol-4.m b/gcc/testsuite/objc/execute/formal_protocol-4.m
new file mode 100644
index 00000000000..af79606c065
--- /dev/null
+++ b/gcc/testsuite/objc/execute/formal_protocol-4.m
@@ -0,0 +1,40 @@
+/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+/* Test defining a protocol, a class adopting it in a category */
+
+@protocol Evaluating
+- (int) importance;
+@end
+
+@interface Feature : Object
+@end
+
+@implementation Feature
+@end
+
+@interface Feature (EvaluatingProtocol) <Evaluating>
+@end
+
+@implementation Feature (EvaluatingProtocol)
+- (int) importance
+{
+ return 1000;
+}
+@end
+
+int main (void)
+{
+ id <Evaluating> object;
+
+ object = [Feature new];
+
+ if ([object importance] != 1000)
+ {
+ abort ();
+ }
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/objc/execute/formal_protocol-5.m b/gcc/testsuite/objc/execute/formal_protocol-5.m
new file mode 100644
index 00000000000..3d9f778fe63
--- /dev/null
+++ b/gcc/testsuite/objc/execute/formal_protocol-5.m
@@ -0,0 +1,33 @@
+/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */
+#include <objc/objc.h>
+#include <objc/Protocol.h>
+
+/* Test defining a protocol, and accessing it using @protocol */
+
+@protocol Evaluating
+- (int) importance;
+@end
+
+/* A class adopting the protocol */
+@interface Test <Evaluating>
+@end
+
+@implementation Test
+- (int) importance
+{
+ return 1000;
+}
+@end
+
+int main (void)
+{
+ Protocol *protocol = @protocol (Evaluating);
+
+ if (strcmp ([protocol name], "Evaluating"))
+ {
+ abort ();
+ }
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/objc/execute/formal_protocol-6.m b/gcc/testsuite/objc/execute/formal_protocol-6.m
new file mode 100644
index 00000000000..7873fdcdf39
--- /dev/null
+++ b/gcc/testsuite/objc/execute/formal_protocol-6.m
@@ -0,0 +1,25 @@
+/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */
+#include <objc/objc.h>
+#include <objc/Protocol.h>
+
+/* Test defining a protocol, and accessing it using @protocol */
+
+@protocol Evaluating
+- (int) importance;
+@end
+
+/* Without a class adopting the protocol - this doesn't work
+ with gcc-2.95.2 as well */
+
+int main (void)
+{
+ Protocol *protocol = @protocol (Evaluating);
+
+ if (strcmp ([protocol name], "Evaluating"))
+ {
+ abort ();
+ }
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/objc/execute/formal_protocol-7.m b/gcc/testsuite/objc/execute/formal_protocol-7.m
new file mode 100644
index 00000000000..14d7594e163
--- /dev/null
+++ b/gcc/testsuite/objc/execute/formal_protocol-7.m
@@ -0,0 +1,44 @@
+/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+#include <objc/Protocol.h>
+
+/* Test defining two protocols, one incorporating the other one. */
+
+@protocol Configuring
+- (void) configure;
+@end
+
+@protocol Processing <Configuring>
+- (void) process;
+@end
+
+/* A class adopting the protocol */
+@interface Test : Object <Processing>
+{
+ BOOL didConfigure;
+ BOOL didProcess;
+}
+@end
+
+@implementation Test
+- (void) configure
+{
+ didConfigure = YES;
+}
+- (void) process
+{
+ didProcess = YES;
+}
+@end
+
+int main (void)
+{
+ id <Processing> object = [Test new];
+
+ [object configure];
+ [object process];
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/objc/execute/informal_protocol.m b/gcc/testsuite/objc/execute/informal_protocol.m
new file mode 100644
index 00000000000..9815053a2e9
--- /dev/null
+++ b/gcc/testsuite/objc/execute/informal_protocol.m
@@ -0,0 +1,13 @@
+/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+@interface Object (StopProtocol)
+- (void) stop;
+@end
+
+int main (void)
+{
+ return 0;
+}
+
diff --git a/gcc/testsuite/objc/execute/initialize.m b/gcc/testsuite/objc/execute/initialize.m
new file mode 100644
index 00000000000..53783982970
--- /dev/null
+++ b/gcc/testsuite/objc/execute/initialize.m
@@ -0,0 +1,36 @@
+/* Contributed by Nicola Pero - Wed Mar 7 17:55:04 CET 2001 */
+#include <objc/objc.h>
+
+/* Test that +initialize is automatically called before the class is
+ accessed */
+
+static int class_variable = 0;
+
+@interface TestClass
+{
+ Class isa;
+}
++ (void) initialize;
++ (int) classVariable;
+@end
+
+@implementation TestClass
++ (void) initialize
+{
+ class_variable = 1;
+}
++ (int) classVariable
+{
+ return class_variable;
+}
+@end
+
+int main (void)
+{
+ if ([TestClass classVariable] != 1)
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/load.m b/gcc/testsuite/objc/execute/load.m
new file mode 100644
index 00000000000..fad662384d6
--- /dev/null
+++ b/gcc/testsuite/objc/execute/load.m
@@ -0,0 +1,30 @@
+/* Contributed by Nicola Pero - Wed Mar 7 17:55:04 CET 2001 */
+#include <objc/objc.h>
+
+/* Test that +load is automatically called before main is run */
+
+static int static_variable = 0;
+
+@interface TestClass
+{
+ Class isa;
+}
++ (void) load;
+@end
+
+@implementation TestClass
++ (void) load
+{
+ static_variable = 1;
+}
+@end
+
+int main (void)
+{
+ if (static_variable != 1)
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/many_args_method.m b/gcc/testsuite/objc/execute/many_args_method.m
new file mode 100644
index 00000000000..d811082cb86
--- /dev/null
+++ b/gcc/testsuite/objc/execute/many_args_method.m
@@ -0,0 +1,56 @@
+/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */
+#include <objc/objc.h>
+
+/* Test the syntax of methods with many arguments */
+
+@interface TestClass
+{
+ Class isa;
+}
++ (int) sumInteger: (int)a withInteger: (int)b;
++ (int) sum: (int)a : (int)b;
++ (int) sumInteger: (int)a withInteger: (int)b withInteger: (int)c;
++ (int) sum: (int)a : (int)b : (int)c;
+@end
+
+@implementation TestClass
++ (int) sumInteger: (int)a withInteger: (int)b
+{
+ return a + b;
+}
++ (int) sum: (int)a : (int)b
+{
+ return [self sumInteger: a withInteger: b];
+}
++ (int) sumInteger: (int)a withInteger: (int)b withInteger: (int)c
+{
+ return a + b + c;
+}
++ (int) sum: (int)a : (int)b : (int)c
+{
+ return [self sumInteger: a withInteger: b withInteger: c];
+}
+@end
+
+
+int main (void)
+{
+ if ([TestClass sumInteger: 1 withInteger: 1] != 2)
+ {
+ abort ();
+ }
+ if ([TestClass sum: 1 : 1] != 2)
+ {
+ abort ();
+ }
+ if ([TestClass sumInteger: 1 withInteger: 1 withInteger: 1] != 3)
+ {
+ abort ();
+ }
+ if ([TestClass sum: 1 : 1 : 1] != 3)
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/nested-3.m b/gcc/testsuite/objc/execute/nested-3.m
new file mode 100644
index 00000000000..94271c4e4c0
--- /dev/null
+++ b/gcc/testsuite/objc/execute/nested-3.m
@@ -0,0 +1,37 @@
+/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */
+#include <objc/objc.h>
+
+/* Test defining a nested function inside a method */
+
+@interface Test
+{
+ Class isa;
+}
++ (int) test;
+@end
+
+@implementation Test
+
++ (int) test
+{
+ int test (void)
+ {
+ return 1;
+ }
+
+ return test ();
+}
+
+@end
+
+int main (void)
+{
+ if ([Test test] != 1)
+ {
+ abort ();
+ }
+
+ return 0;
+}
+
+
diff --git a/gcc/testsuite/objc/execute/no_clash.m b/gcc/testsuite/objc/execute/no_clash.m
new file mode 100644
index 00000000000..7eaa5130727
--- /dev/null
+++ b/gcc/testsuite/objc/execute/no_clash.m
@@ -0,0 +1,41 @@
+/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+/* Test that using the same name for different things makes no
+ problem */
+
+@interface TestClass : Object
+{
+ int test;
+}
++ (int) test;
+- (int) test;
+@end
+
+@implementation TestClass
++ (int) test
+{
+ return 1;
+}
+- (int) test
+{
+ /* 0 + 2 as `test' is implicitly initialized to zero */
+ return test + 2;
+}
+@end
+
+
+int main (void)
+{
+ if ([TestClass test] != 1)
+ {
+ abort ();
+ }
+ if ([[[TestClass alloc] init] test] != 2)
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/private.m b/gcc/testsuite/objc/execute/private.m
new file mode 100644
index 00000000000..02cc23498bd
--- /dev/null
+++ b/gcc/testsuite/objc/execute/private.m
@@ -0,0 +1,32 @@
+/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+/* Test the @private, @protected, @public keyworks for ivars. We only
+ check syntax. */
+
+@interface TestClass : Object
+{
+ int a;
+
+@private
+ int ivarOne, ivarTwo;
+ id ivarThree;
+
+@protected
+ int ivarFour;
+
+@public
+ id ivarFive;
+}
+@end
+
+@implementation TestClass
+@end
+
+
+int main (void)
+{
+ /* Only test compilation */
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/redefining_self.m b/gcc/testsuite/objc/execute/redefining_self.m
new file mode 100644
index 00000000000..93659dbac8d
--- /dev/null
+++ b/gcc/testsuite/objc/execute/redefining_self.m
@@ -0,0 +1,31 @@
+/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */
+#include <objc/objc.h>
+
+/* Test redefining self */
+
+@interface TestClass
+{
+ Class isa;
+}
++ (Class) class;
+@end
+
+@implementation TestClass
++ (Class) class
+{
+ self = Nil;
+
+ return self;
+}
+@end
+
+
+int main (void)
+{
+ if ([TestClass class] != Nil)
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/root_methods.m b/gcc/testsuite/objc/execute/root_methods.m
new file mode 100644
index 00000000000..4f2c2fa0ee4
--- /dev/null
+++ b/gcc/testsuite/objc/execute/root_methods.m
@@ -0,0 +1,42 @@
+/* Contributed by Nicola Pero - Thu Mar 8 16:27:46 CET 2001 */
+#include <objc/objc.h>
+
+/* Test that instance methods of root classes are available as class
+ methods to other classes as well */
+
+@interface RootClass
+{
+ Class isa;
+}
+- (id) self;
+@end
+
+@implementation RootClass
+- (id) self
+{
+ return self;
+}
+@end
+
+@interface NormalClass : RootClass
+@end
+
+@implementation NormalClass : RootClass
+@end
+
+int main (void)
+{
+ Class normal = objc_get_class ("NormalClass");
+
+ if (normal == Nil)
+ {
+ abort ();
+ }
+
+ if ([NormalClass self] != normal)
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/selector-1.m b/gcc/testsuite/objc/execute/selector-1.m
new file mode 100644
index 00000000000..7e21da52a5e
--- /dev/null
+++ b/gcc/testsuite/objc/execute/selector-1.m
@@ -0,0 +1,17 @@
+/* Contributed by Nicola Pero - Thu Mar 8 16:27:46 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+#include <objc/Object.h>
+
+int main (void)
+{
+ SEL selector;
+
+ selector = @selector (alloc);
+ if (strcmp (sel_get_name (selector), "alloc"))
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/static-1.m b/gcc/testsuite/objc/execute/static-1.m
new file mode 100644
index 00000000000..761e7070271
--- /dev/null
+++ b/gcc/testsuite/objc/execute/static-1.m
@@ -0,0 +1,34 @@
+/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */
+#include <objc/objc.h>
+
+/* Test defining a static variable *inside* a class implementation */
+
+@interface Test
+{
+ Class isa;
+}
++ (int) test;
+@end
+
+@implementation Test
+
+static int test = 1;
+
++ (int) test
+{
+ return test;
+}
+
+@end
+
+int main (void)
+{
+ if ([Test test] != 1)
+ {
+ abort ();
+ }
+
+ return 0;
+}
+
+
diff --git a/gcc/testsuite/objc/execute/static-2.m b/gcc/testsuite/objc/execute/static-2.m
new file mode 100644
index 00000000000..52a03a8fbd4
--- /dev/null
+++ b/gcc/testsuite/objc/execute/static-2.m
@@ -0,0 +1,37 @@
+/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */
+#include <objc/objc.h>
+
+/* Test defining a static function *inside* a class implementation */
+
+@interface Test
+{
+ Class isa;
+}
++ (int) test;
+@end
+
+@implementation Test
+
+static int test (void)
+{
+ return 1;
+}
+
++ (int) test
+{
+ return test ();
+}
+
+@end
+
+int main (void)
+{
+ if ([Test test] != 1)
+ {
+ abort ();
+ }
+
+ return 0;
+}
+
+
diff --git a/gcc/testsuite/objc/execute/va_method.m b/gcc/testsuite/objc/execute/va_method.m
new file mode 100644
index 00000000000..bcf43d272a2
--- /dev/null
+++ b/gcc/testsuite/objc/execute/va_method.m
@@ -0,0 +1,44 @@
+/* Contributed by Nicola Pero - Thu Mar 8 16:27:46 CET 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+
+/* Test method with variable number of arguments */
+
+@interface MathClass
+{
+ Class isa;
+}
+/* sum positive numbers; -1 ends the list */
++ (int) sum: (int)firstNumber, ...;
+@end
+
+@implementation MathClass
++ (int) sum: (int)firstNumber, ...
+{
+ va_list ap;
+ int sum = 0, number = 0;
+
+ va_start (ap, firstNumber);
+ number = firstNumber;
+
+ while (number >= 0)
+ {
+ sum += number;
+ number = va_arg (ap, int);
+ }
+
+ va_end (ap);
+
+ return sum;
+}
+@end
+
+int main (void)
+{
+ if ([MathClass sum: 1, 2, 3, 4, 5, -1] != 15)
+ {
+ abort ();
+ }
+
+ return 0;
+}