This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Small C++ PATCH to fix OpenMP threadprivate with templates
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 25 Oct 2012 11:57:47 -0400
- Subject: Small C++ PATCH to fix OpenMP threadprivate with templates
Threadprivate was complaining about a template-id being an incomplete
type, because we weren't calling complete_type to instantiate it.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 055a6956282763467ce0b84776dbb49e89c5a347
Author: Jason Merrill <jason@redhat.com>
Date: Mon Oct 15 11:06:25 2012 -0700
* semantics.c (finish_omp_threadprivate): Call complete_type.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 63b364c..073ee97 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -4360,7 +4360,7 @@ finish_omp_threadprivate (tree vars)
error ("%qE declared %<threadprivate%> after first use", v);
else if (! TREE_STATIC (v) && ! DECL_EXTERNAL (v))
error ("automatic variable %qE cannot be %<threadprivate%>", v);
- else if (! COMPLETE_TYPE_P (TREE_TYPE (v)))
+ else if (! COMPLETE_TYPE_P (complete_type (TREE_TYPE (v))))
error ("%<threadprivate%> %qE has incomplete type", v);
else if (TREE_STATIC (v) && TYPE_P (CP_DECL_CONTEXT (v))
&& CP_DECL_CONTEXT (v) != current_class_type)
diff --git a/gcc/testsuite/g++.dg/gomp/tls-template1.C b/gcc/testsuite/g++.dg/gomp/tls-template1.C
new file mode 100644
index 0000000..5865ce3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/tls-template1.C
@@ -0,0 +1,13 @@
+// { dg-require-effective-target tls }
+
+template <class T> struct B
+{
+ T t;
+};
+
+class A {
+ static B<int> b;
+#pragma omp threadprivate(b)
+};
+
+B<int> A::b;
diff --git a/libgomp/testsuite/libgomp.c++/tls-init1.C b/libgomp/testsuite/libgomp.c++/tls-init1.C
index 4cbaccb..d62e96b 100644
--- a/libgomp/testsuite/libgomp.c++/tls-init1.C
+++ b/libgomp/testsuite/libgomp.c++/tls-init1.C
@@ -1,3 +1,5 @@
+// { dg-require-alias }
+
extern "C" void abort();
struct A