From e73fb06d5a1386fe0a18285d52bcc7865a13a84c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 21 Jun 2019 08:46:45 +0200 Subject: [PATCH] re PR c++/90950 (OpenMP clause handling rejecting references to incomplete types in templates) PR c++/90950 * semantics.c (finish_omp_clauses): Don't reject references to incomplete types if processing_template_decl. * g++.dg/gomp/lastprivate-1.C: New test. From-SVN: r272543 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 3 ++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/gomp/lastprivate-1.C | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/gomp/lastprivate-1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5b659269b1f..c958318abe7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-06-21 Jakub Jelinek + + PR c++/90950 + * semantics.c (finish_omp_clauses): Don't reject references to + incomplete types if processing_template_decl. + 2019-06-19 Marek Polacek PR c++/60364 - noreturn after first decl not diagnosed. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 6cf3af71c21..92c48753d42 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7831,7 +7831,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) t = require_complete_type (t); if (t == error_mark_node) remove = true; - else if (TYPE_REF_P (TREE_TYPE (t)) + else if (!processing_template_decl + && TYPE_REF_P (TREE_TYPE (t)) && !complete_type_or_else (TREE_TYPE (TREE_TYPE (t)), t)) remove = true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 221fb691a12..ab8cc800dd5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-06-21 Jakub Jelinek + PR c++/90950 + * g++.dg/gomp/lastprivate-1.C: New test. + * gcc.dg/vect/vect-simd-11.c: New test. * gcc.target/i386/sse2-vect-simd-11.c: New test. * gcc.target/i386/avx2-vect-simd-11.c: New test. diff --git a/gcc/testsuite/g++.dg/gomp/lastprivate-1.C b/gcc/testsuite/g++.dg/gomp/lastprivate-1.C new file mode 100644 index 00000000000..ce25e1a6b90 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/lastprivate-1.C @@ -0,0 +1,16 @@ +// PR c++/90950 +// { dg-do compile } + +template +T +foo (void) +{ + T y = 0; + T &x = y; + #pragma omp parallel for lastprivate (x) + for (int i = 0; i < 8; ++i) + x = i; + return x; +} + +int a = foo (); -- 2.30.2