PR target/83368
[official-gcc.git] / gcc / testsuite / obj-c++.dg / defs.mm
blob23ba8f91ef602e468b56d84b9c17cb004d9896db
1 /* Check @defs() in Objective-C++ */
2 /* Contributed by Devang Patel  <dpatel@apple.com>  */
3 /* { dg-options "" } */
4 /* { dg-do run } */
5 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
6 #include "../objc-obj-c++-shared/TestsuiteObject.m"
7 #include <stdlib.h>
8 #include <objc/objc.h>
10 extern "C" void abort(void);
12 @interface A : TestsuiteObject
14   @public
15     int a;
17 @end
19 struct A_defs 
21   @defs(A);
24 @implementation A
25 - init 
27   a = 42;
28   return self;
30 @end
33 int main() 
35   A *a = [A init];
36   struct A_defs *a_defs = (struct A_defs *)a;
37   
38   if (a->a != a_defs->a)
39     abort ();   
40   
41   return 0;