Hi!

When I wrote the code, for map clause the arguments couldn't contain any
REF_COMPONENT (nor REF_UNQUIRY nor REF_SUBSTRING) and therefore it was
ok (although unclean) to just look at u.ar.type, but now that REF_COMPONENT
can appear there (so far for OpenACC only, although OpenMP 5.0 also allows
it), that is no longer the case.  Not really sure if the code doesn't need
further changes (how will e.g. var%comp(:) be handled in the mapping
clauses?), but this conditional is clearly wrong.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

2020-01-07  Jakub Jelinek  <ja...@redhat.com>

        PR fortran/93162
        * trans-openmp.c (gfc_trans_omp_clauses): Check for REF_ARRAY type
        before testing u.ar.type == AR_FULL.

--- gcc/fortran/trans-openmp.c.jj       2020-01-04 00:14:28.511400132 +0100
+++ gcc/fortran/trans-openmp.c  2020-01-06 17:01:10.538816323 +0100
@@ -2495,7 +2495,9 @@ gfc_trans_omp_clauses (stmtblock_t *bloc
              tree decl = gfc_trans_omp_variable (n->sym, false);
              if (DECL_P (decl))
                TREE_ADDRESSABLE (decl) = 1;
-             if (n->expr == NULL || n->expr->ref->u.ar.type == AR_FULL)
+             if (n->expr == NULL
+                 || (n->expr->ref->type == REF_ARRAY
+                     && n->expr->ref->u.ar.type == AR_FULL))
                {
                  tree present = gfc_omp_check_optional_argument (decl, true);
                  if (n->sym->ts.type == BT_CLASS)

        Jakub

Reply via email to