#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include "test_support.h"
enum State {
None,
ConstructedA,
ConstructedB,
ConstructedC,
DestroyingB,
DestroyedA,
DestroyedB,
DestroyedC,
};
struct A {
A();
~A();
};
struct B {
B();
~B();
};
struct C {
C();
~C();
};
State state;
A::A() {
if ( state != None ) {
FAIL("should be in the 'None' state");
}
state = ConstructedA;
}
B::B() {
if ( state != ConstructedA ) {
FAIL("should be in the 'ConstructedA' state");
}
state = ConstructedB;
}
C::C() {
if ( state != DestroyingB ) {
FAIL("should be in the 'DestroyingB' state");
}
state = ConstructedC;
}
B::~B() {
if ( state != ConstructedB ) {
FAIL("should be in the 'ConstructedB' state");
}
state = DestroyingB;
static thread_local C c;
if ( state != ConstructedC ) {
FAIL("should be in the 'ConstructedC' state");
}
state = DestroyedB;
}
C::~C() {
if ( state != DestroyedB ) {
FAIL("should be in the 'DestroyedB' state");
}
state = DestroyedC;
}
A::~A() {
if ( state != DestroyedC ) {
FAIL("should be in the 'DestroyedC' state");
}
state = DestroyedA;
PASS("[Success");
}
static void work()
{
thread_local A a = {};
thread_local B b = {};
}
int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
work();
return 0;
}