From patchwork Thu Oct 25 15:57:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Small C++ PATCH to fix OpenMP threadprivate with templates Date: Thu, 25 Oct 2012 05:57:47 -0000 From: Jason Merrill X-Patchwork-Id: 194247 Message-Id: <5089617B.7050103@redhat.com> To: gcc-patches List 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 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 % after first use", v); else if (! TREE_STATIC (v) && ! DECL_EXTERNAL (v)) error ("automatic variable %qE cannot be %", v); - else if (! COMPLETE_TYPE_P (TREE_TYPE (v))) + else if (! COMPLETE_TYPE_P (complete_type (TREE_TYPE (v)))) error ("% %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 struct B +{ + T t; +}; + +class A { + static B b; +#pragma omp threadprivate(b) +}; + +B 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