From e4cc27e5fb5dec11453797a3ba3515bc573839e4 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 11 Oct 2012 11:13:20 -0400 Subject: [PATCH] decl.c (grokdeclarator): Set DECL_GNU_TLS_P for static data members, too. * decl.c (grokdeclarator): Set DECL_GNU_TLS_P for static data members, too. From-SVN: r192366 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 6 +++++- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/gomp/tls-5.C | 3 ++- gcc/testsuite/g++.dg/tls/static2.C | 18 ++++++++++++++++++ gcc/testsuite/g++.dg/tls/thread_local7.C | 2 +- 6 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/tls/static2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a52b643c638..eadfb6ed4d6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2012-10-11 Jason Merrill + + * decl.c (grokdeclarator): Set DECL_GNU_TLS_P for static data + members, too. + 2012-10-09 Dodji Seketeli PR c++/53540 - using fails to be equivalent to typedef diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 0b936ea1a8b..e78c664ba6a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10446,7 +10446,11 @@ grokdeclarator (const cp_declarator *declarator, DECL_EXTERNAL (decl) = 1; if (thread_p) - DECL_TLS_MODEL (decl) = decl_default_tls_model (decl); + { + DECL_TLS_MODEL (decl) = decl_default_tls_model (decl); + if (declspecs->gnu_thread_keyword_p) + DECL_GNU_TLS_P (decl) = true; + } if (constexpr_p && !initialized) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2bb8b925a73..a9ca34141ed 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-10-11 Jason Merrill + + * g++.dg/gomp/tls-5.C: Require tls_native. + * g++.dg/tls/thread_local7.C: Require tls_native. + * g++.dg/tls/static2.C: New. + 2012-10-11 Paolo Carlini PR c++/36107 diff --git a/gcc/testsuite/g++.dg/gomp/tls-5.C b/gcc/testsuite/g++.dg/gomp/tls-5.C index 74e4faaa884..f1dcdae688d 100644 --- a/gcc/testsuite/g++.dg/gomp/tls-5.C +++ b/gcc/testsuite/g++.dg/gomp/tls-5.C @@ -1,6 +1,7 @@ // The reference temp should be TLS, not normal data. // { dg-require-effective-target c++11 } -// { dg-final { scan-assembler-not "\\.data" } } +// { dg-require-alias } +// { dg-final { scan-assembler-not "\\.data" { target tls_native } } } extern int&& ir; #pragma omp threadprivate (ir) diff --git a/gcc/testsuite/g++.dg/tls/static2.C b/gcc/testsuite/g++.dg/tls/static2.C new file mode 100644 index 00000000000..ab688dd8dc4 --- /dev/null +++ b/gcc/testsuite/g++.dg/tls/static2.C @@ -0,0 +1,18 @@ +// { dg-final { scan-assembler-not "_ZTHN1A1iE" } } +// { dg-final { scan-assembler-not "_ZTWN1A1iE" } } +// { dg-require-effective-target tls } + +struct A +{ + static __thread int i; +}; + +int +test () +{ + if (A::i != 8) + return 1; + + A::i = 17; + return 0; +} diff --git a/gcc/testsuite/g++.dg/tls/thread_local7.C b/gcc/testsuite/g++.dg/tls/thread_local7.C index 77a1c05e44c..f453b965768 100644 --- a/gcc/testsuite/g++.dg/tls/thread_local7.C +++ b/gcc/testsuite/g++.dg/tls/thread_local7.C @@ -2,7 +2,7 @@ // { dg-require-effective-target tls } // The reference temp should be TLS, not normal data. -// { dg-final { scan-assembler-not "\\.data" } } +// { dg-final { scan-assembler-not "\\.data" { target tls_native } } } void f() {