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.
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);
--- /dev/null
+! 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