summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc/execute
diff options
context:
space:
mode:
authornicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2001-07-16 11:37:23 +0000
committernicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2001-07-16 11:37:23 +0000
commit28efdc906871f82f86e6a509f8b9e0cdebca1637 (patch)
treebab2edc8e182ee9f48ae933d6430ba30edfe421b /gcc/testsuite/objc/execute
parentaf5fe68cb583388d1e1b4f6b080841d49fb83441 (diff)
downloadgcc-28efdc906871f82f86e6a509f8b9e0cdebca1637.tar.gz
New tests
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44040 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/objc/execute')
-rw-r--r--gcc/testsuite/objc/execute/object_is_class.m42
-rw-r--r--gcc/testsuite/objc/execute/object_is_meta_class.m41
2 files changed, 83 insertions, 0 deletions
diff --git a/gcc/testsuite/objc/execute/object_is_class.m b/gcc/testsuite/objc/execute/object_is_class.m
new file mode 100644
index 00000000000..a053434fb14
--- /dev/null
+++ b/gcc/testsuite/objc/execute/object_is_class.m
@@ -0,0 +1,42 @@
+/* Contributed by Nicola Pero - Tue Jul 3 10:55:21 BST 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+#include <objc/Object.h>
+
+/* This test demonstrate a failure in object_is_class which was fixed */
+
+/* Create a class whose instance variables mirror the struct used for
+ Class structures in the runtime ... yes we're feeling evil today */
+@interface EvilClass : Object
+{
+ Class super_class;
+ const char* name;
+ long version;
+ unsigned long info;
+}
+@end
+
+@implementation EvilClass
+- (id) init
+{
+ self = [super init];
+ /* The following one is used in the runtime to mark classes */
+ info = 0x1L;
+ return self;
+}
+@end
+
+int main (void)
+{
+ /* Create an object of our EvilClass */
+ EvilClass *evilObject = [EvilClass new];
+
+ /* Now check that the object is not a class object */
+ if (object_is_class (evilObject))
+ {
+ printf ("object_is_class failed\n");
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/object_is_meta_class.m b/gcc/testsuite/objc/execute/object_is_meta_class.m
new file mode 100644
index 00000000000..90cd3a962f0
--- /dev/null
+++ b/gcc/testsuite/objc/execute/object_is_meta_class.m
@@ -0,0 +1,41 @@
+/* Contributed by Nicola Pero - Tue Jul 3 10:55:21 BST 2001 */
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+#include <objc/Object.h>
+
+/* This test demonstrate a failure in object_is_meta_class which was fixed */
+
+@interface EvilClass : Object
+{
+ Class super_class;
+ const char* name;
+ long version;
+ unsigned long info;
+}
+@end
+
+@implementation EvilClass
+- (id) init
+{
+ self = [super init];
+ /* The following one is used in the runtime to mark meta classes */
+ info = 0x2L;
+ return self;
+}
+@end
+
+int main (void)
+{
+ /* Create an object of our EvilClass */
+ EvilClass *evilObject = [EvilClass new];
+
+ /* Now check that the object is not a meta class object */
+ if (object_is_meta_class (evilObject))
+ {
+ printf ("object_is_meta_class failed\n");
+ abort ();
+ }
+
+ return 0;
+}
+