aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/obj-c++.dg/defs.mm
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/obj-c++.dg/defs.mm')
-rw-r--r--gcc/testsuite/obj-c++.dg/defs.mm44
1 files changed, 44 insertions, 0 deletions
diff --git a/gcc/testsuite/obj-c++.dg/defs.mm b/gcc/testsuite/obj-c++.dg/defs.mm
new file mode 100644
index 00000000000..b30c328e43b
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/defs.mm
@@ -0,0 +1,44 @@
+/* APPLE LOCAL file mainline */
+/* Check @defs() in Objective-C++ */
+/* Contributed by Devang Patel <dpatel@apple.com> */
+/* { dg-options "-lobjc" } */
+/* { dg-do run } */
+
+
+#include <stdlib.h>
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+extern void abort(void);
+
+@interface A : Object
+{
+ @public
+ int a;
+}
+@end
+
+struct A_defs
+{
+ @defs(A);
+};
+
+@implementation A
+- init
+{
+ a = 42;
+ return self;
+}
+@end
+
+
+int main()
+{
+ A *a = [A init];
+ struct A_defs *a_defs = (struct A_defs *)a;
+
+ if (a->a != a_defs->a)
+ abort ();
+
+ return 0;
+}