1 // Check if the '- .cxx_construct' and '-.cxx_destruct' methods get called
2 // and if they perform their desired function.
4 // { dg-do run { xfail { "*-*-*" } } } PR27247/PR23681
5 // { dg-options "-fobjc-call-cxx-cdtors" }
7 #include <objc/Object.h>
9 #define CHECK_IF(expr) if(!(expr)) abort()
11 static int ctor1_called, ctor2_called, dtor1_called;
27 boo(int _c = 9): c(_c) {
32 @interface Baz: Object {
56 CHECK_IF(!ctor1_called && !ctor2_called && !dtor1_called); /* are we sane? */
59 CHECK_IF(ctor1_called && !ctor2_called && !dtor1_called);
60 CHECK_IF(baz->aa.a == 5 && baz->aa.b == 6);
61 ctor1_called = 0; /* reset */
64 CHECK_IF(!ctor1_called && !ctor2_called && dtor1_called);
65 dtor1_called = 0; /* reset */
68 CHECK_IF(ctor1_called && ctor2_called && !dtor1_called);
69 CHECK_IF(foo->bb.a == 5 && foo->bb.b == 6 && foo->bb.c == 9);
70 CHECK_IF(foo->b.a == 5 && foo->b.b == 6);
71 CHECK_IF(foo->d.a == 5 && foo->d.b == 6);
72 ctor1_called = ctor2_called = 0; /* reset */
75 CHECK_IF(!ctor1_called && !ctor2_called && dtor1_called);