PR c++/66808
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 12 Jan 2016 08:21:53 +0000 (08:21 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 12 Jan 2016 08:21:53 +0000 (08:21 +0000)
PR c++/69000
* pt.c (tsubst_decl): If not local_p, clear DECL_TEMPLATE_INFO.

* g++.dg/tls/pr66808.C: New test.
* g++.dg/tls/pr69000.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232259 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tls/pr66808.C [new file with mode: 0644]
gcc/testsuite/g++.dg/tls/pr69000.C [new file with mode: 0644]

index ba7cf58..c8b8160 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/66808
+       PR c++/69000
+       * pt.c (tsubst_decl): If not local_p, clear DECL_TEMPLATE_INFO.
+
 2016-01-11  Jason Merrill  <jason@redhat.com>
 
        PR c++/69131
index ad5099f..edec774 100644 (file)
@@ -12292,8 +12292,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
            SET_DECL_IMPLICIT_INSTANTIATION (r);
            register_specialization (r, gen_tmpl, argvec, false, hash);
          }
-       else if (!cp_unevaluated_operand)
-         register_local_specialization (r, t);
+       else
+         {
+           if (DECL_LANG_SPECIFIC (r))
+             DECL_TEMPLATE_INFO (r) = NULL_TREE;
+           if (!cp_unevaluated_operand)
+             register_local_specialization (r, t);
+         }
 
        DECL_CHAIN (r) = NULL_TREE;
 
index 97562b9..1866304 100644 (file)
@@ -1,3 +1,10 @@
+2016-01-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/66808
+       PR c++/69000
+       * g++.dg/tls/pr66808.C: New test.
+       * g++.dg/tls/pr69000.C: New test.
+
 2016-01-11  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        * gcc.target/powerpc/swaps-p8-23.c: New test.
diff --git a/gcc/testsuite/g++.dg/tls/pr66808.C b/gcc/testsuite/g++.dg/tls/pr66808.C
new file mode 100644 (file)
index 0000000..e977987
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/66808
+// { dg-do compile { target c++11 } }
+// { dg-require-effective-target tls }
+
+template <typename>
+class A {
+  int *b = foo ();
+  int *foo () { static __thread int a; return &a; }
+};
+A<int> b;
diff --git a/gcc/testsuite/g++.dg/tls/pr69000.C b/gcc/testsuite/g++.dg/tls/pr69000.C
new file mode 100644 (file)
index 0000000..74cdd4b
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/69000
+// { dg-do compile }
+// { dg-require-effective-target tls }
+
+class A {};
+
+template <typename T>
+struct B
+{
+  static int *& foo () { static __thread int *c = 0; return c; }
+};
+
+B<A> d;
+
+void
+bar ()
+{
+  d.foo ();
+}