OSDN Git Service

patch for PR rtl-optimization/25130
[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 -fnext-runtime" }
5
6 #include <objc/objc-runtime.h>
7 #include <stdlib.h>
8 #define CHECK_IF(expr) if(!(expr)) abort()
9
10 #ifndef CLS_HAS_CXX_STRUCTORS
11 #define CLS_HAS_CXX_STRUCTORS 0x2000L
12 #endif
13
14 struct cxx_struct {
15   int a, b;
16   cxx_struct (void) { a = b = 55; }
17 };
18
19 @interface Foo {
20   int c;
21   cxx_struct s;
22 }
23 @end
24
25 @interface Bar: Foo {
26   float f;
27 }
28 @end
29
30 @implementation Foo
31 @end
32
33 @implementation Bar
34 @end
35
36 int main (void)
37 {
38   Class cls;
39
40   cls = objc_getClass("Foo");
41   CHECK_IF(cls->info & CLS_HAS_CXX_STRUCTORS);
42   cls = objc_getClass("Bar");
43   CHECK_IF(!(cls->info & CLS_HAS_CXX_STRUCTORS));
44
45   return 0;
46 }