OSDN Git Service

2010-03-25 Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / obj-c++.dg / cxx-ivars-3.mm
1 // Check if ObjC classes with non-POD C++ ivars are specially marked in the metadata.
2
3 // { dg-do run { target *-*-darwin* } }
4 // { dg-options "-fobjc-call-cxx-cdtors" }
5 // { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } 
6 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
7 #include "../objc-obj-c++-shared/Object1.h"
8 #include "../objc-obj-c++-shared/next-mapping.h"
9
10 #include <stdlib.h>
11 #define CHECK_IF(expr) if(!(expr)) abort()
12
13 #ifndef CLS_HAS_CXX_STRUCTORS
14 #define CLS_HAS_CXX_STRUCTORS 0x2000L
15 #endif
16
17 struct cxx_struct {
18   int a, b;
19   cxx_struct (void) { a = b = 55; }
20 };
21
22 @interface Foo {
23   int c;
24   cxx_struct s;
25 }
26 @end
27
28 @interface Bar: Foo {
29   float f;
30 }
31 @end
32
33 @implementation Foo
34 @end
35
36 @implementation Bar
37 @end
38
39 int main (void)
40 {
41   Class cls;
42
43   cls = objc_get_class("Foo");
44 #if NEXT_OBJC_USE_NEW_INTERFACE
45   CHECK_IF(class_isMetaClass(cls) & CLS_HAS_CXX_STRUCTORS);
46   cls = objc_getClass("Bar");
47   CHECK_IF(!(class_isMetaClass(cls) & CLS_HAS_CXX_STRUCTORS));
48 #else
49   CHECK_IF(cls->info & CLS_HAS_CXX_STRUCTORS);
50   cls = objc_getClass("Bar");
51   CHECK_IF(!(cls->info & CLS_HAS_CXX_STRUCTORS));
52 #endif
53   return 0;
54 }
55 #include "../objc-obj-c++-shared/Object1-implementation.h"