2009-07-17 Richard Guenther <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / obj-c++.dg / defs.mm
blob8b67aab4b9ad2d343653d9fed3440b6e671f8a23
1 /* Check @defs() in Objective-C++ */
2 /* Contributed by Devang Patel  <dpatel@apple.com>  */
4 /* { dg-options "-lobjc" } */
5 /* { dg-do run } */
7 #include <stdlib.h>
8 #include <objc/objc.h>
9 #include <objc/Object.h>
11 extern "C" void abort(void);
13 @interface A : Object
15   @public
16     int a;
18 @end
20 struct A_defs 
22   @defs(A);
25 @implementation A
26 - init 
28   a = 42;
29   return self;
31 @end
34 int main() 
36   A *a = [A init];
37   struct A_defs *a_defs = (struct A_defs *)a;
38   
39   if (a->a != a_defs->a)
40     abort ();   
41   
42   return 0;