Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/g++.dg/tls/thread_local3g.C @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/g++.dg/tls/thread_local3g.C Fri Oct 27 22:46:09 2017 +0900 @@ -0,0 +1,36 @@ +// { dg-do run } +// { dg-require-effective-target c++11 } +// { dg-require-effective-target tls_runtime } +// { dg-require-effective-target pthread } +// { dg-require-cxa-atexit "" } +// { dg-options -pthread } +// { dg-add-options tls } + +int c; +int d; +struct A +{ + A() { ++c; } + ~A() { ++d; } +}; + +thread_local A a; + +void *thread_main(void *) +{ + A* ap = &a; +} + +#include <pthread.h> + +int main() +{ + pthread_t thread; + pthread_create (&thread, 0, thread_main, 0); + pthread_join(thread, 0); + pthread_create (&thread, 0, thread_main, 0); + pthread_join(thread, 0); + + if (c != 2 || d != 2) + __builtin_abort(); +}