From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 8184E385783A; Wed, 21 Jul 2021 07:40:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8184E385783A MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2432] c++: Ensure OpenMP reduction with reference type references complete type [PR101516] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: b3d4011ba10275fbd5d6ec5a16d5aaebbdfb5d3c X-Git-Newrev: aea199f96cf116ba4c81426207acde371556610c Message-Id: <20210721074055.8184E385783A@sourceware.org> Date: Wed, 21 Jul 2021 07:40:55 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jul 2021 07:40:55 -0000 https://gcc.gnu.org/g:aea199f96cf116ba4c81426207acde371556610c commit r12-2432-gaea199f96cf116ba4c81426207acde371556610c Author: Jakub Jelinek Date: Wed Jul 21 09:38:59 2021 +0200 c++: Ensure OpenMP reduction with reference type references complete type [PR101516] The following testcase ICEs because we haven't verified if reduction decl has reference type that TREE_TYPE of the reference is a complete type, require_complete_type on the decl doesn't ensure that. 2021-07-21 Jakub Jelinek PR c++/101516 * semantics.c (finish_omp_reduction_clause): Also call complete_type_or_else and return true if it fails. * g++.dg/gomp/pr101516.C: New test. Diff: --- gcc/cp/semantics.c | 3 ++- gcc/testsuite/g++.dg/gomp/pr101516.C | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b97dc1f6624..331daf81bb7 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -6070,7 +6070,8 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor) if (!processing_template_decl) { t = require_complete_type (t); - if (t == error_mark_node) + if (t == error_mark_node + || !complete_type_or_else (oatype, NULL_TREE)) return true; tree size = size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (oatype), TYPE_SIZE_UNIT (type)); diff --git a/gcc/testsuite/g++.dg/gomp/pr101516.C b/gcc/testsuite/g++.dg/gomp/pr101516.C new file mode 100644 index 00000000000..48f60de6bb0 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr101516.C @@ -0,0 +1,8 @@ +// PR c++/101516 + +void +foo (int (&v) []) +{ + #pragma omp parallel reduction (+:v) // { dg-error "invalid use of array with unspecified bounds" } + ; +}