From 8a8c12a3cd7b8905616680d458249f2ec865396c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 30 May 2011 14:16:04 +0200 Subject: [PATCH] re PR c++/49223 (Internal compiler error when using OpenMP) PR c++/49223 * semantics.c (finish_omp_clauses): Call require_complete_type even for copyin/copyprivate clauses. Only call cxx_omp_create_clause_info if inner_type is COMPLETE_TYPE_P. * g++.dg/gomp/pr49223-1.C: New test. * g++.dg/gomp/pr49223-2.C: New test. From-SVN: r174432 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/semantics.c | 6 ++++-- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/gomp/pr49223-1.C | 28 +++++++++++++++++++++++++++ gcc/testsuite/g++.dg/gomp/pr49223-2.C | 16 +++++++++++++++ 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/gomp/pr49223-1.C create mode 100644 gcc/testsuite/g++.dg/gomp/pr49223-2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 04ae40772bc..24aab154f86 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2011-05-30 Jakub Jelinek + + PR c++/49223 + * semantics.c (finish_omp_clauses): Call require_complete_type + even for copyin/copyprivate clauses. Only call + cxx_omp_create_clause_info if inner_type is COMPLETE_TYPE_P. + 2011-05-28 Jason Merrill PR c++/46124 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 854bac7d6e9..ca9cf4bd130 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4042,12 +4042,13 @@ finish_omp_clauses (tree clauses) break; } - if (need_complete_non_reference) + if (need_complete_non_reference || need_copy_assignment) { t = require_complete_type (t); if (t == error_mark_node) remove = true; - else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE) + else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE + && need_complete_non_reference) { error ("%qE has reference type for %qs", t, name); remove = true; @@ -4089,6 +4090,7 @@ finish_omp_clauses (tree clauses) Save the results, because later we won't be in the right context for making these queries. */ if (CLASS_TYPE_P (inner_type) + && COMPLETE_TYPE_P (inner_type) && (need_default_ctor || need_copy_ctor || need_copy_assignment) && !type_dependent_expression_p (t) && cxx_omp_create_clause_info (c, inner_type, need_default_ctor, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2a504c75e9e..cca41493dab 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-05-30 Jakub Jelinek + + PR c++/49223 + * g++.dg/gomp/pr49223-1.C: New test. + * g++.dg/gomp/pr49223-2.C: New test. + 2011-05-30 Richard Guenther PR tree-optimization/49218 diff --git a/gcc/testsuite/g++.dg/gomp/pr49223-1.C b/gcc/testsuite/g++.dg/gomp/pr49223-1.C new file mode 100644 index 00000000000..307210fe1d2 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr49223-1.C @@ -0,0 +1,28 @@ +// PR c++/49223 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template +struct V +{ + V () {} + ~V () {} +}; + +template +struct S +{ + void foo () + { + V <0> v; + #pragma omp parallel private (v) + ; + } +}; + +void +bar (void) +{ + S <0> s; + s.foo (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr49223-2.C b/gcc/testsuite/g++.dg/gomp/pr49223-2.C new file mode 100644 index 00000000000..95397733ebe --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr49223-2.C @@ -0,0 +1,16 @@ +// PR c++/49223 +// { dg-do compile } +// { dg-require-effective-target tls } +// { dg-options "-fopenmp" } + +struct S; // { dg-error "forward declaration" } +extern __thread struct S s; // { dg-error "has incomplete type" } +struct T; +extern __thread struct T t; + +void +foo () +{ + #pragma omp parallel copyin (s) + ; +} -- 2.30.2