Support C++11 thread_local destructors.
[official-gcc.git] / gcc / testsuite / g++.dg / tls / thread_local3.C
blob461f12676999f2943635ce224e99ee1ac581de0e
1 // { dg-do run }
2 // { dg-require-effective-target c++11 }
3 // { dg-require-effective-target tls_runtime }
4 // { dg-require-effective-target pthread }
5 // { dg-options -pthread }
7 int c;
8 int d;
9 struct A
11   A() { ++c; }
12   ~A() { ++d; }
15 void f()
17   thread_local A a;
20 void *thread_main(void *)
22   f(); f(); f();
25 #include <pthread.h>
27 int main()
29   pthread_t thread;
30   pthread_create (&thread, 0, thread_main, 0);
31   pthread_join(thread, 0);
32   pthread_create (&thread, 0, thread_main, 0);
33   pthread_join(thread, 0);
35   if (c != 2 || d != 2)
36     __builtin_abort();