https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104696

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|fortran                     |middle-end
            Summary|[OpenMP] Implicit mapping   |[OpenMP]
                   |breaks struct mapping       |component/array-ref/compone
                   |                            |nt (x.r[1].d) should use
                   |                            |'x' for GOMP_MAP_STRUCT
                   |                            |(not yield 'x.r[1]' for
                   |                            |nonptr 'x.r')

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Tobias Burnus from comment #4)
>   #pragma omp target map(tofrom: x.r[1].d)
>    *.r[1].d = 3;

s/*/x/

The problem is that in gimplify.cc's gimplify_scan_omp_clauses:

                  tree base
                    = extract_base_bit_offset (OMP_CLAUSE_DECL (c), &base_ref,
                                               &bitpos1, &offset1,
                                               &tree_offset1);
                  bool do_map_struct = (base == decl && !tree_offset1);

Here, 'base' == 'x' but 'decl' is 'x.r[1]' - while for 'x.q.d' it is 'x' (==
base).

The comp refs are removed as follows. (It seems as if some additional ARRAY_REF
checking is needed for non-pointer components.)

              else if (TREE_CODE (decl) == COMPONENT_REF
                       && (OMP_CLAUSE_MAP_KIND (c)
                           != GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION))
                { 
                  component_ref_p = true; 
                  while (TREE_CODE (decl) == COMPONENT_REF)
                    decl = TREE_OPERAND (decl, 0);
                  if (TREE_CODE (decl) == INDIRECT_REF
                      && DECL_P (TREE_OPERAND (decl, 0))
                      && (TREE_CODE (TREE_TYPE (TREE_OPERAND (decl, 0)))
                          == REFERENCE_TYPE))
                    decl = TREE_OPERAND (decl, 0);
                }

Probably the same for '!DECL_P (decl)' in the previous 'if' branch.

Reply via email to