decl.c (grokdeclarator): Set DECL_GNU_TLS_P for static data members, too.
authorJason Merrill <jason@redhat.com>
Thu, 11 Oct 2012 15:13:20 +0000 (11:13 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 11 Oct 2012 15:13:20 +0000 (11:13 -0400)
* decl.c (grokdeclarator): Set DECL_GNU_TLS_P for static data
members, too.

From-SVN: r192366

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/tls-5.C
gcc/testsuite/g++.dg/tls/static2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/tls/thread_local7.C

index a52b643c6387de39a52df77470b6bb9d8daa5eab..eadfb6ed4d6ca4b4ab7f1f9547fec1c9ba89bab8 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-11  Jason Merrill  <jason@redhat.com>
+
+       * decl.c (grokdeclarator): Set DECL_GNU_TLS_P for static data
+       members, too.
+
 2012-10-09  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/53540 - using fails to be equivalent to typedef
index 0b936ea1a8be8b93adb51e4deed4727550c9706b..e78c664ba6a9a32516331786cc47448354c6fd43 100644 (file)
@@ -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)
                  {
index 2bb8b925a739eec27b2af03c93942576f129ca32..a9ca34141edcedbdbe93cec467b06c9426c5103f 100644 (file)
@@ -1,3 +1,9 @@
+2012-10-11  Jason Merrill  <jason@redhat.com>
+
+       * 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  <paolo.carlini@oracle.com>
 
        PR c++/36107
index 74e4faaa88483e6292363f479612c35acfe07e05..f1dcdae688db40bb3ef4d08a1e52a3cad16a3947 100644 (file)
@@ -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 (file)
index 0000000..ab688dd
--- /dev/null
@@ -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;
+}
index 77a1c05e44c5a406979066768c9aa1534b8d2052..f453b96576888a2f3142ae91acd4a32901ba97c0 100644 (file)
@@ -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()
 {