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 "PR27247/PR23681" { *-*-* } { "-fgnu-runtime" } { "" } }
5 // { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } }
6 // { dg-options "-fobjc-call-cxx-cdtors" }
8 #include "../objc-obj-c++-shared/Object1.h"
10 #define CHECK_IF(expr) if(!(expr)) abort()
12 static int ctor1_called, ctor2_called, dtor1_called;
28 boo(int _c = 9): c(_c) {
33 @interface Baz: Object {
57 CHECK_IF(!ctor1_called && !ctor2_called && !dtor1_called); /* are we sane? */
60 CHECK_IF(ctor1_called && !ctor2_called && !dtor1_called);
61 CHECK_IF(baz->aa.a == 5 && baz->aa.b == 6);
62 ctor1_called = 0; /* reset */
65 CHECK_IF(!ctor1_called && !ctor2_called && dtor1_called);
66 dtor1_called = 0; /* reset */
69 CHECK_IF(ctor1_called && ctor2_called && !dtor1_called);
70 CHECK_IF(foo->bb.a == 5 && foo->bb.b == 6 && foo->bb.c == 9);
71 CHECK_IF(foo->b.a == 5 && foo->b.b == 6);
72 CHECK_IF(foo->d.a == 5 && foo->d.b == 6);
73 ctor1_called = ctor2_called = 0; /* reset */
76 CHECK_IF(!ctor1_called && !ctor2_called && dtor1_called);
78 #include "../objc-obj-c++-shared/Object1-implementation.h"