1 // Check if the '- .cxx_construct' and '-.cxx_destruct' methods get called
2 // and if they perform their desired function.
4 // { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } }
5 // { dg-do run { target *-*-darwin* } }
6 // { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } }
7 // { dg-options "-fobjc-call-cxx-cdtors" }
9 #include "../objc-obj-c++-shared/TestsuiteObject.m"
11 #define CHECK_IF(expr) if(!(expr)) abort()
13 static int ctor1_called, ctor2_called, dtor1_called;
29 boo(int _c = 9): c(_c) {
34 @interface Baz: TestsuiteObject {
58 CHECK_IF(!ctor1_called && !ctor2_called && !dtor1_called); /* are we sane? */
61 CHECK_IF(ctor1_called && !ctor2_called && !dtor1_called);
62 CHECK_IF(baz->aa.a == 5 && baz->aa.b == 6);
63 ctor1_called = 0; /* reset */
66 CHECK_IF(!ctor1_called && !ctor2_called && dtor1_called);
67 dtor1_called = 0; /* reset */
70 CHECK_IF(ctor1_called && ctor2_called && !dtor1_called);
71 CHECK_IF(foo->bb.a == 5 && foo->bb.b == 6 && foo->bb.c == 9);
72 CHECK_IF(foo->b.a == 5 && foo->b.b == 6);
73 CHECK_IF(foo->d.a == 5 && foo->d.b == 6);
74 ctor1_called = ctor2_called = 0; /* reset */
77 CHECK_IF(!ctor1_called && !ctor2_called && dtor1_called);