From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 065D03839834; Thu, 17 Jun 2021 05:59:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 065D03839834 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 r11-8591] openmp: Gimplify OMP_CLAUSE_SIZE during gfc_omp_finish_clause [PR100965] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: ce1dd5e70514fde8e34c86ab45a3c55e84d3c5b7 X-Git-Newrev: 1f94733aea11b6e729dcb8c5824239af7e2a690b Message-Id: <20210617055929.065D03839834@sourceware.org> Date: Thu, 17 Jun 2021 05:59:29 +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: Thu, 17 Jun 2021 05:59:29 -0000 https://gcc.gnu.org/g:1f94733aea11b6e729dcb8c5824239af7e2a690b commit r11-8591-g1f94733aea11b6e729dcb8c5824239af7e2a690b Author: Jakub Jelinek Date: Wed Jun 9 10:48:41 2021 +0200 openmp: Gimplify OMP_CLAUSE_SIZE during gfc_omp_finish_clause [PR100965] As the testcase shows, we need to gimplify OMP_CLAUSE_SIZE, so that we don't end up with SAVE_EXPR or anything similar non-gimple in it. 2021-06-08 Jakub Jelinek PR fortran/100965 * trans-openmp.c (gfc_omp_finish_clause): Gimplify OMP_CLAUSE_SIZE. * gfortran.dg/gomp/pr100965.f90: New test. (cherry picked from commit d4d38135b3137f1d3148138340e67bdcd7ea8216) Diff: --- gcc/fortran/trans-openmp.c | 3 +++ gcc/testsuite/gfortran.dg/gomp/pr100965.f90 | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 349df1cc346..7e931bf4bc7 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -1478,6 +1478,9 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p, bool openacc) OMP_CLAUSE_SIZE (c) = DECL_P (decl) ? DECL_SIZE_UNIT (decl) : TYPE_SIZE_UNIT (TREE_TYPE (decl)); + if (gimplify_expr (&OMP_CLAUSE_SIZE (c), pre_p, + NULL, is_gimple_val, fb_rvalue) == GS_ERROR) + OMP_CLAUSE_SIZE (c) = size_int (0); if (c2) { OMP_CLAUSE_CHAIN (c2) = OMP_CLAUSE_CHAIN (last); diff --git a/gcc/testsuite/gfortran.dg/gomp/pr100965.f90 b/gcc/testsuite/gfortran.dg/gomp/pr100965.f90 new file mode 100644 index 00000000000..9044547df6e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr100965.f90 @@ -0,0 +1,16 @@ +! PR fortran/100965 +! { dg-do compile } + +implicit none + character(len=:), allocatable :: s + logical :: l + !$omp target map(from: l) + l = allocated (s) + !$omp end target + if (l) stop 1 + + !$omp target map(from: l) + l = allocated (s) + !$omp end target + if (l) stop 2 +end