In gcc/:
[gcc.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 -mmacosx-version-min=10.4" }
6 // This test has no equivalent or meaning for m64/ABI V2
7 // { dg-xfail-run-if "No Test Avail" { *-*-darwin* && lp64 } { "-fnext-runtime" } { "" } }
8
9 #include <objc/objc-runtime.h>
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 #ifndef __LP64__
42 Class cls;
43
44 cls = objc_getClass("Foo");
45 CHECK_IF(cls->info & CLS_HAS_CXX_STRUCTORS);
46 cls = objc_getClass("Bar");
47 CHECK_IF(!(cls->info & CLS_HAS_CXX_STRUCTORS));
48
49 #else
50 /* No test needed or available. */
51 abort ();
52 #endif
53 return 0;
54 }