diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/tls/thread_local2g.C')
-rw-r--r-- | gcc/testsuite/g++.dg/tls/thread_local2g.C | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/tls/thread_local2g.C b/gcc/testsuite/g++.dg/tls/thread_local2g.C new file mode 100644 index 0000000000..8304a4d2f9 --- /dev/null +++ b/gcc/testsuite/g++.dg/tls/thread_local2g.C @@ -0,0 +1,28 @@ +// { dg-do run { target c++11 } } +// { dg-add-options tls } +// { dg-require-effective-target tls_runtime } + +extern "C" void abort(); + +struct A +{ + A(); + int i; +}; + +thread_local A a; + +A &f() +{ + return a; +} + +int j; +A::A(): i(j) { } + +int main() +{ + j = 42; + if (f().i != 42) + abort (); +} |