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

            Bug ID: 109831
           Summary: [OpenMP] Handle absent optional arguments in depend,
                    has_device_addr, to/from and allocatable/pointer vars
                    in map
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

ISSUE 1: allocatated/associated vs. present cannot be distinguished for scalar
allocatables/pointers, i.e.

subroutine foo(x)
  integer, allocatable, optional :: x
  !$omp target
     if (.not.present(x))
       print *, "not present"
     else if (.not. allocated(x)) then 
       print *, "not allocated"
     else
       print *, "value: ", x
     end if
  !$omp end target
end

Does not work correctly as we pass 'x == NULL ? NULL : *x' as argument
to the map. We should map *x (if present) and a pointer variable to which we
attach the *x pointer.


ISSUE 2: Extend the set of permitted clauses.

Absent optionals are permitted for some other clauses besides 'map'. Per
post-TR11 discussions (→ OpenMP Spec issue #3490), there are *not* permitted
...

* ... for variables that are evaluated in a clause such as 'if(...)'
* ... for variables that are privatized ('firstprivate', 'private',
'is_device_ptr')
* ... at places where the clause poses restrictions that can only be fulfilled
when the variable is present – like 'copyprivate' (argument must be privatized,
hence, it has to exist)

Besides 'map', that's the case for
* the 'to'/from' motion clauses
* has_device_addr
* depend
* < something else ? >

Reply via email to