public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-1319] openmp: Gimplify OMP_CLAUSE_SIZE during gfc_omp_finish_clause [PR100965]
Date: Wed,  9 Jun 2021 08:49:46 +0000 (GMT)	[thread overview]
Message-ID: <20210609084946.609173857033@sourceware.org> (raw)

https://gcc.gnu.org/g:d4d38135b3137f1d3148138340e67bdcd7ea8216

commit r12-1319-gd4d38135b3137f1d3148138340e67bdcd7ea8216
Author: Jakub Jelinek <jakub@redhat.com>
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  <jakub@redhat.com>
    
            PR fortran/100965
            * trans-openmp.c (gfc_omp_finish_clause): Gimplify OMP_CLAUSE_SIZE.
    
            * gfortran.dg/gomp/pr100965.f90: New test.

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 c8c61a54582..f466ab675c3 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -1639,6 +1639,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


                 reply	other threads:[~2021-06-09  8:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210609084946.609173857033@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).