OSDN Git Service

a3c4b0c492a8cbcf35cdf0ea6d36376862782e69
[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-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } 
5 // { dg-options "-fobjc-call-cxx-cdtors" }
6 // { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } }
7
8 #include "../objc-obj-c++-shared/Object1.h"
9 #include "../objc-obj-c++-shared/next-mapping.h"
10
11 #include <stdlib.h>
12 #define CHECK_IF(expr) if(!(expr)) abort()
13
14 #ifndef CLS_HAS_CXX_STRUCTORS
15 #define CLS_HAS_CXX_STRUCTORS 0x2000L
16 #endif
17
18 struct cxx_struct {
19   int a, b;
20   cxx_struct (void) { a = b = 55; }
21 };
22
23 @interface Foo {
24   int c;
25   cxx_struct s;
26 }
27 @end
28
29 @interface Bar: Foo {
30   float f;
31 }
32 @end
33
34 @implementation Foo
35 @end
36
37 @implementation Bar
38 @end
39
40 int main (void)
41 {
42   Class cls;
43
44   cls = objc_get_class("Foo");
45 #if NEXT_OBJC_USE_NEW_INTERFACE
46   CHECK_IF(class_isMetaClass(cls) & CLS_HAS_CXX_STRUCTORS);
47   cls = objc_getClass("Bar");
48   CHECK_IF(!(class_isMetaClass(cls) & CLS_HAS_CXX_STRUCTORS));
49 #else
50   CHECK_IF(cls->info & CLS_HAS_CXX_STRUCTORS);
51   cls = objc_getClass("Bar");
52   CHECK_IF(!(cls->info & CLS_HAS_CXX_STRUCTORS));
53 #endif
54   return 0;
55 }
56 #include "../objc-obj-c++-shared/Object1-implementation.h"